IPhone: CGRectIntersectsRect ()
I found this lattice method in the documentation. This method returns true if one CGRect overlaps with another. Is there any possibility or another method that only returns true if one Rect1 intersects Rect2 by more than 50%? if less than false.
+3
Jim
source
to share
1 answer
When you use CGRectIntersectsRect (), you get a CGrect, which is the intersection of both rectanlges, so based on the area of ββthat rectangle, you can get if it's more than 50%.
Something like that:
CGrect *interRect = CGRectIntersection(rect1, rect2);
if ((interRect.size. width * interRect.size.height) > (rect2.size. width * rect2.size.height*0.5) return Yes;
I am multiplying the width * height to get the area of ββthe rectangle.
+6
Antonio MG
source
to share