From 05ce156764c2b458306ea35d52247753528a5ade Mon Sep 17 00:00:00 2001 From: Xenon Date: Wed, 23 Sep 2015 04:23:11 +0300 Subject: [PATCH] Added support for SDWebImageAvoidAutoSetImage option to UIButton and highlighted UIImageView --- SDWebImage/UIButton+WebCache.m | 14 ++++++++++++-- SDWebImage/UIImageView+HighlightedWebCache.m | 7 ++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/SDWebImage/UIButton+WebCache.m b/SDWebImage/UIButton+WebCache.m index 33f7c29c..5bf66201 100644 --- a/SDWebImage/UIButton+WebCache.m +++ b/SDWebImage/UIButton+WebCache.m @@ -74,7 +74,12 @@ static char imageURLStorageKey; dispatch_main_sync_safe(^{ __strong UIButton *sself = wself; if (!sself) return; - if (image) { + if (image && (options & SDWebImageAvoidAutoSetImage) && completedBlock) + { + completedBlock(image, error, cacheType, url); + return; + } + else if (image) { [sself setImage:image forState:state]; } if (completedBlock && finished) { @@ -117,7 +122,12 @@ static char imageURLStorageKey; dispatch_main_sync_safe(^{ __strong UIButton *sself = wself; if (!sself) return; - if (image) { + if (image && (options & SDWebImageAvoidAutoSetImage) && completedBlock) + { + completedBlock(image, error, cacheType, url); + return; + } + else if (image) { [sself setBackgroundImage:image forState:state]; } if (completedBlock && finished) { diff --git a/SDWebImage/UIImageView+HighlightedWebCache.m b/SDWebImage/UIImageView+HighlightedWebCache.m index eed798f7..921134e5 100644 --- a/SDWebImage/UIImageView+HighlightedWebCache.m +++ b/SDWebImage/UIImageView+HighlightedWebCache.m @@ -39,7 +39,12 @@ dispatch_main_sync_safe (^ { if (!wself) return; - if (image) { + if (image && (options & SDWebImageAvoidAutoSetImage) && completedBlock) + { + completedBlock(image, error, cacheType, url); + return; + } + else if (image) { wself.highlightedImage = image; [wself setNeedsLayout]; }