Function

CGRectIntersection

Returns the intersection of two rectangles.

Declaration

CGRect CGRectIntersection(CGRect r1, CGRect r2);

Parameters

r1

The first source rectangle.

r2

The second source rectangle.

Return Value

A rectangle that represents the intersection of the two specified rectangles. If the two rectangles do not intersect, returns the null rectangle. To check for this condition, use CGRectIsNull.

Discussion

Both rectangles are standardized prior to calculating the intersection.

See Also

Modifying Rectangles

CGRectDivide

Divides a source rectangle into two component rectangles.

CGRectInset

Returns a rectangle that is smaller or larger than the source rectangle, with the same center point.

CGRectIntegral

Returns the smallest rectangle that results from converting the source rectangle values to integers.

CGRectOffset

Returns a rectangle with an origin that is offset from that of the source rectangle.

CGRectStandardize

Returns a rectangle with a positive width and height.

CGRectUnion

Returns the smallest rectangle that contains the two source rectangles.