Add an option called "SDWebImageAvoidAutoImageFill" to avoid automatic image addition in UIImageView and let developer to do it himself

This commit is contained in:
Jean-Charles SORIN 2015-06-18 19:18:45 +02:00
parent 48d10c1773
commit 5d2963ac73
2 changed files with 13 additions and 1 deletions

View File

@ -82,6 +82,13 @@ typedef NS_OPTIONS(NSUInteger, SDWebImageOptions) {
* Use this flag to transform them anyway. * Use this flag to transform them anyway.
*/ */
SDWebImageTransformAnimatedImage = 1 << 10, SDWebImageTransformAnimatedImage = 1 << 10,
/**
* By default, image is added to the imageView after download. But in some cases, we want to
* have the hand before setting the image (apply a filter or add it with cross-fade animation for instance)
* Use this flag if you want to manually set the image in the completion when success
*/
SDWebImageAvoidAutoImageFill = 1 << 11
}; };
typedef void(^SDWebImageCompletionBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL); typedef void(^SDWebImageCompletionBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL);

View File

@ -54,7 +54,12 @@ static char imageURLKey;
if (!wself) return; if (!wself) return;
dispatch_main_sync_safe(^{ dispatch_main_sync_safe(^{
if (!wself) return; if (!wself) return;
if (image) { if (image && (options & SDWebImageAvoidAutoImageFill) && completedBlock)
{
completedBlock(image, error, cacheType, url);
return;
}
else if (image) {
wself.image = image; wself.image = image;
[wself setNeedsLayout]; [wself setNeedsLayout];
} else { } else {