简体   繁体   中英

Animate the CHANGE of UIImageView only one image

I have a UIImageView that I would like to change its image with animation. I checked how to animate a UIImageView with an array but I don't wanna use many image.

I just wanna change the current image with aa new one using any kind of animation only once.

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.

I think you can find your answer on this

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM