G.P.Reddy
G.P.Reddy

Reputation: 556

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.

Upvotes: 4

Views: 3664

Answers (1)

Suresh Thoutam
Suresh Thoutam

Reputation: 258

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

Upvotes: 1

Related Questions