Detecting if UIView is intersecting other UIViews

前端 未结 4 987
谎友^
谎友^ 2020-12-03 09:35

I have a bunch of UIViews on the screen. I would like to know what\'s the best to way to check if a particular view (which I have reference to) is intersection ANY other vie

4条回答
  •  無奈伤痛
    2020-12-03 09:55

    First, create some array that stores the frames of all of your UIViews and their associated reference.

    Then, potentially in a background thread, you can run some collision testing using what's in the array. For some simple collision testing for rectangles only, check out this SO question: Simple Collision Algorithm for Rectangles

    Hope that helps!

提交回复
热议问题