i create an array of 2 images, animate then and everything work perfectly. but now i want the animation to stop after one repeat, i mean that the animation will start with the first image, move to second one and stop (and the second image will stay on my imageview). how can i do it? here is my code:
UIImage *mistakeOne = [UIImage imageNamed:@"Xmark.png"];
UIImage *mistakeOneB = [UIImage imageNamed:@"XmarkWhite.png"];
NSMutableArray *animation = [[NSMutableArray alloc] initWithObjects:mistakeOne, mistakeOneB , nil];
[mistakeNumberOne setAnimationImages:animation];
mistakeNumberOne.animationDuration = 5.0;
[mistakeNumberOne startAnimating]
thanks!
Assuming mistakeNumberOne is a UIImageView
[mistakeNumberOne animationRepeatCount:1];
If you want to keep an image after the animation set the desired image in the UIImageview before the animation:
mistakeNumberOne.image = myDesiredImage;
After the animation it will show the image.
Putting it all together:
UIImage *mistakeOne = [UIImage imageNamed:@"Xmark.png"];
UIImage *mistakeOneB = [UIImage imageNamed:@"XmarkWhite.png"];
NSMutableArray *animation = [[NSMutableArray alloc] initWithObjects:mistakeOne, mistakeOneB , nil];
[mistakeNumberOne setAnimationImages:animation];
mistakeNumberOne.animationDuration = 5.0;
[mistakeNumberOne animationRepeatCount:1];
mistakeNumberOne.image = mistakeOneB;
[mistakeNumberOne startAnimating];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With