2014-10-08 159 views
3

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

下面的代码:

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

在此先感谢。

+1

试试这个http://stackoverflow.com/questions/17864292/uiimageviewanimatedgif-always-loops和http://stackoverflow.com/questions/9744682/display-animated-gif-in-ios – 2014-10-08 08:49:22

回答

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