iOS OC 加载 本地网络GIF图片

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(@"")];

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

推荐阅读更多精彩内容