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图