一个异步的 GIF 图片类和图片查看器,支持播放/停止 GIF 图片。
它仅使用很少的内存。以下 GIF 通常将占用几乎 600MB 内存(800x600x389x4 字节),但使用 YLGIFImage,它仅占用大约 30MB 内存。
对于这个 gif 文件,iOS Pinterest 也会崩溃,但使用 YLGIFImage,它不会!
使用 CocoaPods 入门,您可以将以下行添加到 Podfile 中
pod 'YLGIFImage'
对于使用 YLGIFImage,非常简单
YLImageView* imageView = [[YLImageView alloc] initWithFrame:CGRectMake(0, 160, 320, 240)];
[self.view addSubview:imageView];
imageView.image = [YLGIFImage imageNamed:@"joy.gif"];
以下是一个示例代码的样子
感谢 OLImageView!我参考了该项目的很多地方,特别是使用 CADisplayLink 来播放动画。