A smart, quick iOS image loader by David Young
- Image Cache 图片缓存
- Multithread optimization, avoid repeated loading 多线程优化,避免重复加载
- import the .h file 导入.h文件
#import "DYImageLoader.h"
- use DYImageLoader 使用DYImageLoader
DYImageLoader * imageLoader = DYImageLoader.sharedImageLoader;
- loadImageWithURL
- (void)loadImageWithURL:(NSString*)url completion:(void (^)(UIImage* _Nullable image))completion;
异步加载图片,优先从图片缓存中读取,如果没有则发起请求;多个线程同时发起针对同一URL的请求将只保留一个
- loadImageForUIImageView
- (void)loadImageForUIImageView:(UIImageView*)uiImageView withURL:(NSString*)url completion:(void (^)(void))completion;
调用loadImageWithURL,之后为UIImageView设置image
- loadImageForUIImageViews
- (void)loadImageForUIImageViews:(NSArray*)uiImageViews withURL:(NSString*)url;
调用loadImageWithURL,之后为数组中所有UIImageView设置image