通过重写pointInside方法
hitAreaPadding 是传入的size 可以定义为属性
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
{
if (self.hidden || self.alpha == 0 || self.userInteractionEnabled == NO || self.enabled == NO) {
return NO;
}
CGRect bounds = self.bounds;
bounds = CGRectInset(bounds, -self.hitAreaPadding.width, -self.hitAreaPadding.height);
return CGRectContainsPoint(bounds, point);
}
来源:https://www.cnblogs.com/KingQiangzi/p/9883274.html
重写按钮的 hitTets 方法,判断 point 是否属于扩大范围内,属于就返回 self,让自己作为响应者
网友评论