Skip to content

Commit

Permalink
添加背景图下载
Browse files Browse the repository at this point in the history
  • Loading branch information
songwentong committed Jul 30, 2014
1 parent f6e2164 commit e403b9f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
Binary file not shown.
7 changes: 7 additions & 0 deletions WTRequestCenter/UIKit+WTRequestCenter/UIButton+WTImageCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 18 additions & 0 deletions WTRequestCenter/UIKit+WTRequestCenter/UIButton+WTImageCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit e403b9f

Please sign in to comment.