简体   繁体   中英

How to limit user interaction to an area inside UIView?

Here is a UIView, which is the yellow rectangle, and I override the drawRect: method to draw the red area, and I added the UITapGesture etc. but I just wanna to respond the red area, if the user click inside the yellow rectangle, but not on the red area, I will not respond it. Do I need to manually get the position and calculate whether it is inside the scope? Any smartier way to do so? Thanks. 在此处输入图片说明

我知道的唯一解决方案是实现gestureRecognizer:shouldReceiveTouch:委托方法,并验证您的触摸是否在红色矩形的内部/外部。

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