static void * MyObjectMyCustomPorpertyKey = (void *)@"MyObjectMyCustomPorpertyKey";
@implementation UIImageView (CanClick)
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
UITapGestureRecognizer *tapGes = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapGesPressed)];
[self addGestureRecognizer:tapGes];
}
return self;
}
- (NSString *)clickUrl {
return objc_getAssociatedObject(self,MyObjectMyCustomPorpertyKey);
}
- (void)setClickUrl:(NSString *)clickUrl {
objc_setAssociatedObject(self, MyObjectMyCustomPorpertyKey,clickUrl, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
- (void)tapGesPressed {
[[SchemeHandler defaultHandler]handleUrl:self.clickUrl animated:YES];
}
网友评论