SDWebImage4.0之前
1 UIImageView *imgView = [UIImageView new]; 2 imgView.contentMode = UIViewContentModeScaleAspectFit; 3 imgView.frame = CGRectMake(0, 0, 100, 30); 4 5 NSString *filePath = [[NSBundle bundleWithPath:[[NSBundle mainBundle] bundlePath]]pathForResource:@"going" ofType:@"gif"]; 6 NSData *imageData = [NSData dataWithContentsOfFile:filePath]; 7 imgView.backgroundColor = [UIColor clearColor]; 8 imgView.image = [UIImage sd_animatedGIFWithData:imageData]; 9 [self addSubview:imgView];
SDWebImage4.0之后
1 FLAnimatedImageView *imgView = [FLAnimatedImageView new]; 2 imgView.contentMode = UIViewContentModeScaleAspectFit; 3 imgView.frame = CGRectMake(0, 0, 100, 30); 4 NSString *filePath = [[NSBundle bundleWithPath:[[NSBundle mainBundle] bundlePath]]pathForResource:@"going" ofType:@"gif"]; 5 NSData *imageData = [NSData dataWithContentsOfFile:filePath]; 6 imgView.backgroundColor = [UIColor clearColor]; 7 imgView.animatedImage = [FLAnimatedImage animatedImageWithGIFData:imageData]; 8 [self addSubview:imgView];