SDWebImageManager *sSDWebImageManager sharedManager];标签:缓存,MYLog,url,image,cachedImage,block,使用,SDWebImage,图片 From: https://blog.51cto.com/u_15907570/5925300
UIImage *cachedImage = [sdManager imageWithUrl:url];// 将需要缓存的图片加载进来
//如果缓存中有图片
if (cachedImage) {
MYLog(@"有缓存图片");
[button setBackgroundImage:cachedImage forState:UIControlStateNormal];
}else
{
//如果缓存中没有图片,异步下载图片
MYLog(@"正在下载图片%@",url);
[sdManager downloadWithURL:url options:0 progress:^(NSUInteger receivedSize, long long expectedSize) {
} completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished) {
if (image) {
MYLog(@"下载完成的图片");
[button setBackgroundImage:image forState:UIControlStateNormal];
}
}];
}