I have an image that is animating, until you press the button that says "Stop". The code works and all, but the image returns to the first image in the array. How can i add a code to tell it to stop at the image it's currently at?
- (void)viewDidLoad {
[super viewDidLoad];
imageView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"a0001.png"],
[UIImage imageNamed:@"a0002.png"],
[UIImage imageNamed:@"a0003.png"],
[UIImage imageNamed:@"a0004.png"],
[UIImage imageNamed:@"a0005.png"], nil];
imageView.animationDuration = 3.00;
imageView.animationRepeatCount = 0;
[imageView startAnimating];
[self.view addSubview:imageView];
}
- (IBAction)stopAni {
[imageView stopAnimating];
}
Thanks
Thanks dean, hey I need you once again :p now I've been able to stop it where I want, can I make it continue the animation where it has stopped??
Set the image property of the UIImageView to be the one you want to stop at
- (IBAction)stopAni {
[imageView stopAnimating];
[imageView setImage:[[imageView animationImages] objectAtIndex:currentFrame];
}
The current frame is just the animation duration divided by the amount of time that you have been animatin (you'll have to store the time that you started animating yourself!)
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