I'm using few gesture recognizers on some views, but sometimes views are too small and it's hard to hit it. Using recognizers is necessary, so how can I enlarge hit area?
A pan gesture occurs any time a person moves one or more fingers around the screen. A screen-edge pan gesture is a specialized pan gesture that originates from the edge of the screen. Use the UIPanGestureRecognizer class for pan gestures and the UIScreenEdgePanGestureRecognizer class for screen-edge pan gestures.
A gesture recognizer decouples the logic for recognizing a sequence of touches (or other input) and acting on that recognition.
Swift version of @rmaddy answer:
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
let frame = self.bounds.insetBy(dx: -20, dy: -20);
return frame.contains(point) ? self : nil;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With