applemavs
applemavs

Reputation: 503

iOS Swift - Making Tap Gesture Recognizer work beneath views

Is it possible to place a Tap Gesture Recognizer on a view in such a way that even if another view is on top, a tap in that location will always register? For example, View 1 has a Tap Gesture Recognizer outlet. View 2 would be placed on top of View 1. I want the Tap Gesture Recognizer of View 1 to still be called when the user taps on View 2 in the area where View 1 would be if not covered by View 2.

Solutions in Swift preferred.

Upvotes: 1

Views: 542

Answers (1)

nRewik
nRewik

Reputation: 9148

set view2.userInteractionEnabled = false.

user events for view2 will be ignored and removed from the event queue.

The event will fall to the below view, in this case view1.

Upvotes: 1

Related Questions