【发布时间】:2020-05-29 11:05:41
【问题描述】:
我有一个以 .gif 结尾的 gif 图像,它可以在 android 手机和 chrome 上正确显示。 Iphone 无法显示 gif。下面是它应该是什么样子的图像,以及它在 Iphone 上显示的图像。
iphone im 测试用的是 Iphone 6 ios 11.4
iphone 上的 gif 图像,因为它没有显示出来。
闪烁的 gif 显示在其他浏览器和手机上。
【问题讨论】:
我有一个以 .gif 结尾的 gif 图像,它可以在 android 手机和 chrome 上正确显示。 Iphone 无法显示 gif。下面是它应该是什么样子的图像,以及它在 Iphone 上显示的图像。
iphone im 测试用的是 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];
});
};
【讨论】: