Вам лучше использовать свойство UIImageView - animationImages
.
@property(nonatomic,copy) NSArray *animationImages;
Например, у вас есть UIImageView* animationImageView
:
// pass NSArray of UIImage's in the order of desired appearance
animationImageView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"image1"],
[UIImage imageNamed:@"image2"],
[UIImage imageNamed:@"image3"],
[UIImage imageNamed:@"image4"],
[UIImage imageNamed:@"image5"], nil];
animationImageView.animationDuration = 1.5; // duration (seconds) of ONE animation cycle
animationImageView.animationRepeatCount = 3; // number of repeats (cycles)
animationImageView startAnimating];
Если вы хотите запустить другое действие , когда анимация заканчивается , используйте dispatch_after
:
dispatch_time_t animTime = dispatch_time(DISPATCH_TIME_NOW, animationImageView.animationDuration * NSEC_PER_SEC);
dispatch_after (popTime, dispatch_get_main_queue(), ^(void){
// do your stuff
[self animationDidFinish];
});