1.创建一个类继承UIView
2.初始化方法使用:
- (id)initWithTarget:(id)aTarget action:(SEL)aAction
{
self = [super init];
if (self == nil) {
_target= aTarget;
_action = aAction;
}
return self;
}
3.在touchesBegan中实现目标方法
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[_target performSelector:_action withObject:self];
}