Bigair
Bigair

Reputation: 1592

How to enable touch only on subviews

I have two views. A base view "View A" and its subview "View B"

I implemented tap gesture on View A and I want to enable that gesture only on View B, not View A which has actual gesture implementation.

View B may be transformed by GCAffineTransform( angle may be set ).

enter image description here

Upvotes: 0

Views: 169

Answers (1)

Bankim
Bankim

Reputation: 254

Make class conforming to UIGestureRecognizerDelegate.

Then make self as the UITapGestureRecognizer delegate.

Implement the below method.

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(nonnull UITouch *)touch {

  if (touch.view.tag == tagOfBlueView) {
    return YES;
  }
  return NO;
}

Upvotes: 2

Related Questions