setImageWithURL:placeholderImage:options:
会先把 placeholderImage 显示,然后 SDWebImageManager 根据 URL 开始处理图片。downloadWithURL:delegate:options:userInfo:
,交给 SDImageCache
从缓存查找图片是否已经下载 queryDiskCacheForKey:delegate:userInfo:
.imageCache:didFindImage:forKey:userInfo:
到 SDWebImageManager。webImageManager:didFinishWithImage:
到 UIImageView+WebCache 等前端展示图片。notifyDelegate:
。 imageCache:didFindImage:forKey:userInfo:
。进而回调展示图片。imageCache:didNotFindImageForKey:userInfo:
。SDWebImageDownloader
开始下载图片。connection:didReceiveData:
中利用 ImageIO 做了按图片下载进度加载效果。connectionDidFinishLoading:
数据下载完成后交给 SDWebImageDecoder
做图片解码处理。notifyDelegateOnMainThreadWithInfo:
宣告解码完成,imageDecoder:didFinishDecodingImage:userInfo:
回调给 SDWebImageDownloader。imageDownloader:didFinishWithImage:
回调给 SDWebImageManager 告知图片下载完成。UIButton+WebCache
和 MKAnnotationView+WebCache
,方便使用。SDWebImagePrefetcher
可以预先下载图片,方便后续使用。