简体   繁体   中英

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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM