Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当拖动到另一个子视图顶部以查看它是否发生碰撞时,我试图检测一个子视图。有什么好的方法可以做到这一点?我正在使用 UIPanGestureRecognizer 来拖动元素。谢谢
您可以CGRectIntersectsRect()用于执行任务:
CGRectIntersectsRect()
if(CGRectIntersectsRect(firstSubview.frame, secondSubview.frame)) { //collides, do your task here }