Skip to content

Instantly share code, notes, and snippets.

@Josscii
Last active May 3, 2020 07:37
Show Gist options
  • Save Josscii/7a1665445bff4a2a1e000985dd2a1bf4 to your computer and use it in GitHub Desktop.
Save Josscii/7a1665445bff4a2a1e000985dd2a1bf4 to your computer and use it in GitHub Desktop.
增大 button 的可点击范围,之所以写了两种,是因为第二种有可能会被其他重写或者 oc category 给覆盖掉。
class EnlargeButton: UIButton {
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
return bounds.insetBy(dx: -20, dy: -20).contains(point)
}
}
extension UIButton {
open override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
return bounds.insetBy(dx: -20, dy: -20).contains(point)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment