Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A Swift UIButton extension to ensure the hit-zone is at least 44x44
import UIKit
class MinimumTouchAreaButton: UIButton {
override func hitTest(_ point: CGPoint, with _: UIEvent?) -> UIView? {
guard !isHidden, isUserInteractionEnabled, alpha > 0 else {
return nil
let expandedBounds = bounds.insetBy(dx: min(bounds.width - 44.0, 0), dy: min(bounds.height - 44.0, 0))
return expandedBounds.contains(point) ? self : nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment