这是一个如何使用 imageEdgeInsets 的简单示例 这将使一个 20x20 按钮的可点击区域变大 10 像素(40x40)
var expandHittableAreaAmt: CGFloat = 10
var buttonWidth: CGFloat = 20
var button = UIButton.buttonWithType(UIButtonType.Custom) as UIButton
button.frame = CGRectMake(0, 0,
buttonWidth + expandHittableAreaAmt*2,
buttonWidth + expandHittableAreaAmt*2)
button.imageEdgeInsets = UIEdgeInsetsMake(expandHittableAreaAmt,
expandHittableAreaAmt, expandHittableAreaAmt, expandHittableAreaAmt)
button.setImage(UIImage(named: "buttonImage"), forState: .Normal) //20x20 image
button.addTarget(self, action: "didTouchButton:", forControlEvents: .TouchUpInside)