#import
<objc/runtime.h>
//objc_setAssociatedObject
需要四个参数:源对象,关键字,关联的对象和一个关联策略。
objc_setAssociatedObject
(button,
buttonKey
, _imgView,
OBJC_ASSOCIATION_RETAIN_NONATOMIC
);
- (
void
)buttonPress:(
UIButton
*)sender
//headButton
点击
{
UIImageView
*imageView =
objc_getAssociatedObject
(sender,
buttonKey
);
}
guan