Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stopping the animation of GIF

Here i am using the uiimage-from-animated-gif library to show an animated GIF through a UIImage. It's working, but I need to stop the animation, imageView after one complete revolution.

The following code:

NSURL *url = [[NSBundle mainBundle] URLForResource:@"dove-animate" withExtension:@"gif"];
self.imageView.image = [UIImage animatedImageWithAnimatedGIFData:[NSData dataWithContentsOfURL:url]];

Thanks in advance.

like image 381
G.P.Reddy Avatar asked Jan 22 '26 14:01

G.P.Reddy


1 Answers

url = [[NSBundle mainBundle] URLForResource:@"dove-animate" withExtension:@"gif"];
UIImage *testImage = [UIImage animatedImageWithAnimatedGIFData:[NSData dataWithContentsOfURL:url]];
self.imageView.image = [UIImage animatedImageWithAnimatedGIFData:[NSData dataWithContentsOfURL:url]];
self.imageView.animationImages = testImage.images;
self.imageView.animationDuration = testImage.duration;
self.imageView.animationRepeatCount = 1;
self.imageView.image = testImage.images.lastObject;
[self.imageView startAnimating];



Use the above code it will works
like image 100
Suresh Thoutam Avatar answered Jan 25 '26 12:01

Suresh Thoutam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!