我有一个以.gif结尾的gif图像,它在Android手机和Chrome上正确显示。 iPhone无法显示gif。下面是它的外观以及在Iphone上显示的图像。
正在测试的iPhone是Iphone 6 ios 11.4
iphone上的gif图片,因为它没有显示。
在其他浏览器和电话上显示gif闪烁。
如果在项目中使用SDWebImage库进行图像加载和缓存,则会找到一个名为FLAnimatedImage的类。使用此功能,您可以轻松集成GIF。
FLAnimatedImage *image = [[FLAnimatedImage alloc] initWithAnimatedGIFData:[NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"<your_file_name>" ofType:@"gif"]]];
[yourImageView setAnimatedImage:image];
__weak typeof(self) weakself = self;
yourImageView.loopCompletionBlock = ^(NSUInteger loopCountRemaining) {
dispatch_async(dispatch_get_main_queue(), ^{
[weakself.yourImageView startAnimating];
});
};