Ios 如何知道UIScrollView是否与另一个视图的CGPoint相交

Ios 如何知道UIScrollView是否与另一个视图的CGPoint相交,ios,swift,uiscrollview,uikit,uitouch,Ios,Swift,Uiscrollview,Uikit,Uitouch,我有两个UIScrollView。它们不是彼此的子视图。其中一个作为覆盖层位于另一个之上,用于获得此效果: 现在,我在第二个滚动视图(位于下方)上有一个ui按钮。 我无法点击此按钮,因为顶部滚动视图正在捕获所有触摸 这就是我想要实现的目标。但是我被卡住了 我在UIScrollView上放置了一个可识别的UITapGestureRecognitor 我想转换水龙头的CG点,并将其转换到第二个滚动视图上的位置 如果该点与第二个UIScrollView上的UIButton位置相交,则我将只打印一条消

我有两个UIScrollView。它们不是彼此的子视图。其中一个作为覆盖层位于另一个之上,用于获得此效果:

现在,我在第二个滚动视图(位于下方)上有一个
ui按钮。
我无法点击此按钮,因为顶部滚动视图正在捕获所有触摸

这就是我想要实现的目标。但是我被卡住了

  • 我在UIScrollView上放置了一个可识别的UITapGestureRecognitor
  • 我想转换水龙头的CG点,并将其转换到第二个滚动视图上的位置
  • 如果该点与第二个UIScrollView上的UIButton位置相交,则我将只打印一条消息
  • 这是我的密码。请帮我看看有什么问题:

    @IBAction func bufferviewCliked (sender: UITapGestureRecognizer) {
        // First I try to get the point of the object clicked inside as a point on
        // the main self.view
        let locationInMainView = sender.location(in: self.view)
    
        // Next I try to convert that point, into a point on my backgroundScrollView
        let touchPointInSecondView = self.view.convert(locationInMainView, from: backGround)
    
        // If the point intersects with the point on the UIButton in the backgroundScrollView
        // Then print hi
        if followButton.frame.contains(touchPointInSecondView) {
            print("HI")
        }
    }
    

    问题是我的点坐标是错误的,我不确定我是否使用了正确的东西。

    您可以从按钮获取位置视图

    @IBAction func bufferviewCliked (sender: UITapGestureRecognizer) {
       let location = sender.location(in: followButton)
    
       // If the point intersects with the point on the UIButton in the backgroundScrollView
       // Then print hi
       if followButton.bounds.contains(location) {
            print("HI")
       }
    }