SDWebImage
pod 'SDWebImage', '4.4.3'
pod 'SDWebImage/GIF', '4.4.3'
pod 'FLAnimatedImage', '1.0.12'
#import "FLAnimatedImageView.h"
#import <FLAnimatedImageView+WebCache.h>
@interface MessageTypeImageView : BaseMessageView
@property (nonatomic, strong) FLAnimatedImageView *contentImageView;
@end
#本地gif
NSURL *localUrl = [NSURL fileURLWithPath:model.imageFilePath];
NSData *imageData = [NSData dataWithContentsOfURL:localUrl];
self.contentImageView.animatedImage = [FLAnimatedImage animatedImageWithGIFData:imageData];
#网络gif
NSURL *url = [NSURL URLWithString:model.URL];
[self.contentImageView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"icon_placeholder"]];
SDWebImage
pod 'YYWebImage', '~> 1.0.4'
#import "YYAnimatedImageView.h"
@interface MessageTypeImageView : BaseMessageView
@property (nonatomic, strong) YYAnimatedImageView *contentImageView;
@end
#本地gif
YYImage *yyimage = [YYImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:model.imageFilePath]]];
self.contentImageView.image = yyimage;
#网络gif
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://%@%@",[JSPPAccountManager sharedManager].raddrURL,item.content.image.URL]];
[self.contentImageView yy_setImageWithURL:url placeholder:kImageNamed(@"")];