SDWebImage源码阅读(十七)UIImageView+HighlightedWebCache

  这个分类只是为 UIImageView 的 highlightedImage 赋图。

1 @property (nullable, nonatomic, strong) UIImage *highlightedImage NS_AVAILABLE_IOS(3_0); // default is nil

  

 1 - (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url
 2                               options:(SDWebImageOptions)options
 3                              progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock
 4                             completed:(nullable SDExternalCompletionBlock)completedBlock {
 5     __weak typeof(self)weakSelf = self;
 6     [self sd_internalSetImageWithURL:url
 7                     placeholderImage:nil
 8                              options:options
 9                         operationKey:@"UIImageViewImageOperationHighlighted"
10                        setImageBlock:^(UIImage *image, NSData *imageData) {
11                            weakSelf.highlightedImage = image;
12                        }
13                             progress:progressBlock
14                            completed:completedBlock];
15 }

  这个是该分类里面所有下载图片的方法最后都会调取的方法,同 UIButton 一样,也是调用 UIView 的 WebCache 分类里面下载图片的方法。下载完成后:

1 weakSelf.highlightedImage = image;

END 

  

posted @ 2017-06-11 12:07  鳄鱼不怕牙医不怕  阅读(304)  评论(0编辑  收藏  举报