SD_WebImage加载gif图片

sd_webimage更新4.0.0后,之前的加载gif图的两个方法sd_animatedGIFNamed  || sd_animatedGIFWithData都已经被修改了,当你仍然调用这两个方法的时候,出来的是静态图

4.0.0之后加了一个FLAnimatedImage类来显示gif图

1:首先用法是,导入第三方

pod'SDWebImage'

pod'SDWebImage/GIF'

2:导入头文件

#import "FLAnimatedImageView+WebCache.h"

3:使用FLAnimatedImage创建一个对象(用法和UIImageView相似)

FLAnimatedImageView *imgView = [FLAnimatedImageView new];

imgView.contentMode = UIViewContentModeScaleAspectFit;imgView.frame = CGRectMake(30,20, 50, 50);

NSString  *filePath = [[NSBundlebundleWithPath:[[NSBundlemainBundle]bundlePath]]pathForResource:@"loading"ofType:@"gif"];NSData  *imageData = [NSData dataWithContentsOfFile:filePath];

imgView.backgroundColor= [UIColor clearColor];imgView.animatedImage = [FLAnimatedImage animatedImageWithGIFData:imageData];[loadingViewaddSubview:imgView];

当然在这里只是加载少量gif图

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容