参考:
http://www.jianshu.com/p/f0530a75c7af https://github.com/Flipboard/FLAnimatedImage
马蛋的一个加载的菊花不转了
发现
// NSString *path = [[NSBundle mainBundle] pathForResource:@"spin" ofType:@"gif"]; // NSData *data = [NSData dataWithContentsOfFile:path]; // UIImage *image = [UIImage sd_animatedGIFWithData:data]; // cell.loadingImg.image=image;
这个不能用了 重要的是 :
sd的sd_animatedGIFWithData方法返回的image只包含第一帧。
找了新方法
使用FLAnimatedImageView。
#import <FLAnimatedImage/FLAnimatedImageView.h>
#import <FLAnimatedImage/FLAnimatedImage.h>
NSString *path = [[NSBundle mainBundle] pathForResource:@"spin" ofType:@"gif"];
NSData *data = [NSData dataWithContentsOfFile:path];
FLAnimatedImage *image = [FLAnimatedImage animatedImageWithGIFData:data];
FLAnimatedImageView *imageView = [FLAnimatedImageView new];
imageView.animatedImage = image;