Add imageURL property to remaining categories
This commit is contained in:
parent
77be243598
commit
825207d1d0
|
|
@ -14,6 +14,14 @@
|
|||
*/
|
||||
@interface MKAnnotationView (WebCache)
|
||||
|
||||
/**
|
||||
* Get the current image URL.
|
||||
*
|
||||
* Note that because of the limitations of categories this property can get out of sync
|
||||
* if you use setImage: directly.
|
||||
*/
|
||||
- (NSURL *)imageURL;
|
||||
|
||||
/**
|
||||
* Set the imageView `image` with an `url`.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -9,11 +9,18 @@
|
|||
#import "MKAnnotationView+WebCache.h"
|
||||
#import "objc/runtime.h"
|
||||
|
||||
static char imageURLKey;
|
||||
static char operationKey;
|
||||
|
||||
@implementation MKAnnotationView (WebCache)
|
||||
|
||||
- (void)setImageWithURL:(NSURL *)url {
|
||||
- (NSURL *)imageURL;
|
||||
{
|
||||
return objc_getAssociatedObject(self, &imageURLKey);
|
||||
}
|
||||
|
||||
- (void)setImageWithURL:(NSURL *)url
|
||||
{
|
||||
[self setImageWithURL:url placeholderImage:nil options:0 completed:nil];
|
||||
}
|
||||
|
||||
|
|
@ -36,6 +43,7 @@ static char operationKey;
|
|||
- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock {
|
||||
[self cancelCurrentImageLoad];
|
||||
|
||||
objc_setAssociatedObject(self, &imageURLKey, url, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
self.image = placeholder;
|
||||
|
||||
if (url) {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,14 @@
|
|||
*/
|
||||
@interface UIButton (WebCache)
|
||||
|
||||
/**
|
||||
* Get the current image URL.
|
||||
*
|
||||
* Note that because of the limitations of categories this property can get out of sync
|
||||
* if you use setImage: directly.
|
||||
*/
|
||||
- (NSURL *)currentImageURL;
|
||||
|
||||
/**
|
||||
* Set the imageView `image` with an `url`.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -9,11 +9,18 @@
|
|||
#import "UIButton+WebCache.h"
|
||||
#import "objc/runtime.h"
|
||||
|
||||
static char imageURLKey;
|
||||
static char operationKey;
|
||||
|
||||
@implementation UIButton (WebCache)
|
||||
|
||||
- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state {
|
||||
- (NSURL *)currentImageURL;
|
||||
{
|
||||
return objc_getAssociatedObject(self, &imageURLKey);
|
||||
}
|
||||
|
||||
- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state
|
||||
{
|
||||
[self setImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil];
|
||||
}
|
||||
|
||||
|
|
@ -36,6 +43,7 @@ static char operationKey;
|
|||
- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock {
|
||||
[self cancelCurrentImageLoad];
|
||||
|
||||
objc_setAssociatedObject(self, &imageURLKey, url, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
[self setImage:placeholder forState:state];
|
||||
|
||||
if (url) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue