In xcode, how do I make an animation stop on an Image?
I know the 'nil' clear开发者_JAVA技巧s the imageView at the end of the animation. But is there a way to end it on one of the images? When I run it without 'nil' at the end it's a lovely error.
imageView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"image1.png"],
[UIImage imageNamed:@"image2.png"],
[UIImage imageNamed:@"image3.png"],
[UIImage imageNamed:@"image4.png"],
[UIImage imageNamed:@"image5.png"],
[UIImage imageNamed:@"image6.png"],
[UIImage imageNamed:@"image7.png"],
[UIImage imageNamed:@"image8.png"],
[UIImage imageNamed:@"image9.png"],
[UIImage imageNamed:@"image10.png"],
[UIImage imageNamed:@"image0.png"],nil];
imageView.animationDuration = 0.50;
[imageView setAnimationRepeatCount: 1];
[imageView startAnimating];
I don't think there's a way to directly do this, but you could do something like:
//set your animationImages as stated in the question
[imageView setAnimationDuration:0.5];
[imageView setAnimationRepeatCount:1];
[imageView startAnimating];
[imageView performSelector:@selector(setImage:) withObject:theFinalImage afterDelay:[imageVIew animationDuration]];
Basically, you're going to run through the animations once, then replace the animation images with the final static image.
精彩评论