Detect if certain UIView was touched amongst other UIViews

后端 未结 8 1620
迷失自我
迷失自我 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 03:02

    My swift version to check that touch took place in infoView:

    override func touchesBegan(_ touches: Set, with event: UIEvent?) {
        guard let touch = touches.first, infoView.bounds.contains(touch.location(in: infoView))  else { return }
        print("touchesBegan") // Replace by your own code
    } // touchesBegan
    

提交回复
热议问题