我创建了一个具有更大命中区域的UIButton。 但现在我想改变/调整其命中区域。 无论如何要改变它而不重新创建UIButton对象?
我只看到pointInside函数,但无法找到更新特定UIButton更大命中区域的方法吗?
var buttonMargin:UIEdgeInsets = UIEdgeInsetsMake(-7,-2.5,-7,-2.5)
override func pointInside(point: CGPoint, withEvent event: UIEvent?) -> Bool {
let relativeFrame = self.bounds
//var hitTestEdgeInsets = UIEdgeInsetsMake(-5, -5, -5, -5)
let hitFrame = UIEdgeInsetsInsetRect(relativeFrame, buttonMargin)
return CGRectContainsPoint(hitFrame, point)
}