UIButton . 扩大点击区域 重写下面的方法

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