1.框架下载地址:
https://github.com/SDWebImage/SDWebImage
2.命令:
pod 'SDWebImage'
3.导入文件
#import "SDAnimatedImageView.h"
#import "SDAnimatedImageView+WebCache.h"
4.控件初始化
@property (nonatomic, strong) SDAnimatedImageView *bannerView;
.......................................
_bannerView = [[SDAnimatedImageView alloc] init];
_bannerView.backgroundColor = [UIColor clearColor];
_bannerView.contentMode = UIViewContentModeScaleAspectFit;
_bannerView.userInteractionEnabled = YES;
[self.contentView addSubview:_bannerView];
/// 布局代码
[_bannerView mas_makeConstraints:^(MASConstraintMaker *make) {
}];
5.赋值使用
/// _urlString 为服务器返回的链接
NSString *_urlString = @"https://sxxxxxxx.gif";
[self.bannerView sd_setImageWithURL:[NSURL URLWithString:_urlString]];
/// 此方法也兼容 .png .jpg
网友评论