I am having my UIImageView
onto which I am having another UIView
rectangle. By applying pan gesture to UIView
rectangle it gets outsi
Instead of manually computing whether the points are within the view's bounds, use CGRectContainsPoint(rect, point)
. This is what works for me, and I like it because it's shorter and more readable:
func handlePan(pan: UIPanGestureRecognizer) {
switch pan.state {
case .Began:
if CGRectContainsPoint(self.pannableView.frame, pan.locationInView(self.pannableView)) {
// Gesture started inside the pannable view. Do your thing.
}
}