淡入/溶解改变的UIImageView的图像时, [英] Fade/dissolve when changing UIImageView's image

查看:209
本文介绍了淡入/溶解改变的UIImageView的图像时,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

而不是创建两个的UIImageViews ,它似乎是合乎逻辑简单地改变一个视图的图片。如果我这样做,反正是有具有两个图像之间的淡入/交叉解散,而不是瞬间切换的?

Rather than creating two UIImageViews, it seems logical to simply change the image of one view. If I do that, is there anyway of having a fade/cross dissolve between the two images rather than an instant switch?

推荐答案

编辑:有来自 @algal一个更好的解决方案下面

there is a better solution from @algal below.

另一种方式做,这是通过使用predefined CAAnimation转换:

Another way to do this is by using predefined CAAnimation transitions:

CATransition *transition = [CATransition animation];
transition.duration = 0.25;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFade;
transition.delegate = self;
[self.view.layer addAnimation:transition forKey:nil];
view1.hidden = YES;
view2.hidden = NO;

请参阅苹果的视图过渡示例项目:<一href=\"http://developer.apple.com/library/ios/#sample$c$c/ViewTransitions/Introduction/Intro.html#//apple_ref/doc/uid/DTS40007411\">http://developer.apple.com/library/ios/#sample$c$c/ViewTransitions/Introduction/Intro.html#//apple_ref/doc/uid/DTS40007411

See the View Transitions example project from Apple: http://developer.apple.com/library/ios/#samplecode/ViewTransitions/Introduction/Intro.html#//apple_ref/doc/uid/DTS40007411

这篇关于淡入/溶解改变的UIImageView的图像时,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆