CGRectIntersectsRect returns whether two rectangles intersect in iOS, macOS, tvOS and watchOS.
CGRectIntersectsRect is going to return true if any part of rect1 lies inside of rect2.
CGRectIntersectsRect is useful for more than just selections. You can use it to see if you need to draw something. If you’re managing a bunch of objects being drawn in a view, call CGRectIntersectsRect with the visible rectangle as a very fast test to see if you should draw that object or not. The questions related to this can be tagged with cgrectintersectsrect.
Resource:
Reference:
CGRectIntersectsrect Class reference
Sample:
CGRect container = CGRectMake (0.0, 0.0, 100.0, 200.0);
CGPoint point = CGPointMake (50.0, 100.0);
if (CGRectContainsPoint(container, point)) {
NSLog (@"contains point!");
}
Related SO questions: