Detect if certain UIView was touched amongst other UIViews

后端 未结 8 1629
迷失自我
迷失自我 2020-11-30 02:30

I have 3 UIViews, layered on top of one large uiview. I want to know if the user touches the top one and not care about the other ones. I will have a couple of buttons in th

8条回答
  •  悲哀的现实
    2020-11-30 02:53

    In my case the UIView I wanted to find was not returned by the hitTest. But the following code worked better:

        CGPoint locationPoint = [[touches anyObject] locationInView:self.view];
        CGPoint viewPoint = [myImage convertPoint:locationPoint fromView:self.view];
        if ([myImage pointInside:viewPoint withEvent:event]) {
           // do something
        }
    

提交回复
热议问题