给UIbutton写一个继承,重写point方法
class ZQButton:UIButton{
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
let zqmargin:CGFloat = -10
let clickArea = bounds.insetBy(dx: zqmargin, dy: zqmargin)
return clickArea.contains(point)
}
}
参考: