diff --git a/WTRequestCenter.xcodeproj/project.xcworkspace/xcuserdata/songwt.xcuserdatad/UserInterfaceState.xcuserstate b/WTRequestCenter.xcodeproj/project.xcworkspace/xcuserdata/songwt.xcuserdatad/UserInterfaceState.xcuserstate index 13a58a6..39df351 100644 Binary files a/WTRequestCenter.xcodeproj/project.xcworkspace/xcuserdata/songwt.xcuserdatad/UserInterfaceState.xcuserstate and b/WTRequestCenter.xcodeproj/project.xcworkspace/xcuserdata/songwt.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/WTRequestCenter/UIKit+WTRequestCenter/UIButton+WTImageCache.h b/WTRequestCenter/UIKit+WTRequestCenter/UIButton+WTImageCache.h index c8fc2d1..b455593 100644 --- a/WTRequestCenter/UIKit+WTRequestCenter/UIButton+WTImageCache.h +++ b/WTRequestCenter/UIKit+WTRequestCenter/UIButton+WTImageCache.h @@ -16,4 +16,11 @@ - (void)setImageForState:(UIControlState)state withURL:(NSURL *)url placeholderImage:(UIImage *)placeholderImage; + +- (void)setBackgroundImage:(UIControlState)state + withURL:(NSURL *)url; + +- (void)setBackgroundImage:(UIControlState)state + withURL:(NSURL *)url + placeholderImage:(UIImage *)placeholderImage; @end diff --git a/WTRequestCenter/UIKit+WTRequestCenter/UIButton+WTImageCache.m b/WTRequestCenter/UIKit+WTRequestCenter/UIButton+WTImageCache.m index 5ee500c..36936a2 100644 --- a/WTRequestCenter/UIKit+WTRequestCenter/UIButton+WTImageCache.m +++ b/WTRequestCenter/UIKit+WTRequestCenter/UIButton+WTImageCache.m @@ -24,4 +24,22 @@ - (void)setImageForState:(UIControlState)state [self setImage:image forState:state]; }]; } + +- (void)setBackgroundImage:(UIControlState)state + withURL:(NSURL *)url +{ + [self setBackgroundImage:state withURL:url placeholderImage:nil]; +} + +- (void)setBackgroundImage:(UIControlState)state + withURL:(NSURL *)url + placeholderImage:(UIImage *)placeholderImage +{ + [self setBackgroundImage:placeholderImage forState:state]; + [WTRequestCenter getImageWithURL:url completionHandler:^(UIImage *image) { + [self setBackgroundImage:image forState:state]; + }]; +} + + @end