Detect collision of two UIView's in swift

后端 未结 2 905
北荒
北荒 2020-12-11 17:22

I have two UIViews on my ViewController. I added panGesture to first view and when i start moving this view the second view will move towards first view. I want to detect an

相关标签:
2条回答
  • 2020-12-11 17:59

    Swift 3 CGRectIntersectsRect replace with intersects

    for collider in colliders
            {
                if (collider.frame.intersects(frameTarget)) {
                    return
                }
            }
    
    0 讨论(0)
  • 2020-12-11 18:05

    what about

    if (CGRectIntersectsRect(secondView.frame, sender.frame)) {
            // Do something
        }
    

    CGRectIntersectsRect(::) : Returns whether two rectangles intersect.

    0 讨论(0)
提交回复
热议问题