Skip to content

Commit

Permalink
Added support for SDWebImageAvoidAutoSetImage option to UIButton and …
Browse files Browse the repository at this point in the history
…highlighted UIImageView
  • Loading branch information
xzenon committed Sep 23, 2015
1 parent 14842f6 commit 05ce156
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
14 changes: 12 additions & 2 deletions SDWebImage/UIButton+WebCache.m
Expand Up @@ -74,7 +74,12 @@ - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placehold
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) {
Expand Down Expand Up @@ -117,7 +122,12 @@ - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state
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) {
Expand Down
7 changes: 6 additions & 1 deletion SDWebImage/UIImageView+HighlightedWebCache.m
Expand Up @@ -39,7 +39,12 @@ - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)op
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];
}
Expand Down

0 comments on commit 05ce156

Please sign in to comment.