[英]Animate the CHANGE of UIImageView only one image
I have a UIImageView that I would like to change its image with animation.我有一个 UIImageView,我想用 animation 更改它的图像。 I checked how to animate a UIImageView with an array but I don't wanna use many image.
我检查了如何使用数组为 UIImageView 设置动画,但我不想使用很多图像。
I just wanna change the current image with aa new one using any kind of animation only once.我只想使用任何类型的 animation 将当前图像更改为新图像一次。
Just put the below code:只需输入以下代码:
#import <QuartzCore/QuartzCore.h>
...
imageView.image = [UIImage imageNamed:"The image name"];
CATransition *transition = [CATransition animation];
transition.duration = 1.0f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFade;
[imageView.layer addAnimation:transition forKey:nil];
I think you are searchig for this......我想你正在搜索这个......
The animationImages property works equally well with one image in it, or multiple. animationImages属性同样适用于其中的一个或多个图像。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.