停止GIF的动画

时间:2014-10-08 08:21:41

标签: ios objective-c iphone cocoa-touch ios8

我在这里使用uiimage-from-animated-gif库通过UIImage显示动画GIF。它工作正常,但我需要在完成一次革命后停止动画imageView

以下代码:

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

提前致谢。

1 个答案:

答案 0 :(得分:0)

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