我们在SDWebImage 4.0之前,如果直接使用sd_setImageWithURL:(nullable NSURL *)url completed:(nullable SDExternalCompletionBlock)completedBlock是可以显示gif图像的,但是在4.0之后我们会发现在github上面,SDWebImage上面有这么一段话,大致的意思就是如果再4.0开始,我们还需要去加载动图的话,我们就需要给我们的项目中再增加一个框架,把pod 'SDWebImage/GIF'
写到你的podfile文件中,然后再去下载就可以了。然后我们在项目中如果想让一个imageView实现加载url会去加载动图的话,把创建对象本来是UIImageView的对象改成FLAnimatedImageView的对象。也就是说本来我们是这样创建的
fileprivate lazy var imageView = UIImageView()
改成这样就可以了
fileprivate lazy var imageView = FLAnimatedImageView()
这里补充下 FLAnimatedImageView的animatedImage的posterImage;表示的是GIF动画的封面帧图片,那个animatedImage;表示设置GIF动画数据,UIImage *currentFrame;表示GIF动画当前显示的帧图片,currentFrameIndex;//GIF动画当前显示的帧图片索引