Skip to content

Instantly share code, notes, and snippets.

@projectfebr
Created June 30, 2022 08:40
Show Gist options
  • Select an option

  • Save projectfebr/770d6b5abccef6056402cf8a1e297997 to your computer and use it in GitHub Desktop.

Select an option

Save projectfebr/770d6b5abccef6056402cf8a1e297997 to your computer and use it in GitHub Desktop.
Расширение области для тапа
class ButtonWithTouchSize: UIButton {
var touchAreaPadding: UIEdgeInsets?
override func point(inside point: CGPoint,
with event: UIEvent?) -> Bool
{
guard let insets = touchAreaPadding else {
return super.point(inside: point, with: event)
}
let rect = UIEdgeInsetsInsetRect(bounds, insets.inverted())
return rect.contains(point)
}
}
extension UIEdgeInsets {
func inverted() -> UIEdgeInsets {
return UIEdgeInsets(top: -top, left: -left,
bottom: -bottom, right: -right)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment