Is there any method in iPhone to find the intersection of two custom UIView (lets say two views are circular and are开发者_StackOverflow社区 in same super view). If there is no such method, what is the best way to achieve this goal.
You could use CGRectIntersectsRect.
CGRectIntersectsRect
Returns whether two rectangles intersect.
bool CGRectIntersectsRect (
CGRect rect1,
CGRect rect2
);
Parameters
rect1
The first rectangle to examine.
rect2
The second rectangle to examine.
There's an example on this question Objective-C: Issue with CGRect .frame intersect/contains
UIView
s are all of rectangular shape.
If you need custom shapes, you need to check for yourself. With circular shapes, this is not complicated (take distance of centers and the radius of each one).
精彩评论