我想在UIImageView中使用gif,但我不能.我的代码是:
- (void)viewDidLoad {
[super viewDidLoad];
NSURL *url = [[NSBundle mainBundle] URLForResource:@"test" withExtension:@"gif"];
UIImage *testImage = [UIImage animatedImageWithAnimatedGIFData:[NSData dataWithContentsOfURL:url]];
self.dataImageView.animationImages = testImage.images;
self.dataImageView.animationDuration = testImage.duration;
self.dataImageView.animationRepeatCount = 1;
self.dataImageView.image = testImage.images.lastObject;
[self.dataImageView startAnimating];
}
Run Code Online (Sandbox Code Playgroud)
迅速:
var url : NSURL = NSBundle.mainBundle().URLForResource("MAES", withExtension: "gif")
Run Code Online (Sandbox Code Playgroud)
在目标CI中有animatedImageWithAnimatedGIFData,但在swift中我不知道如何调用此或如果不存在..
谢谢!