Structure

CGRect

A structure that contains the location and dimensions of a rectangle.

Declaration

typedef struct CGRect {
    ...
} CGRect;

Overview

In the default Core Graphics coordinate space, the origin is located in the lower-left corner of the rectangle and the rectangle extends towards the upper-right corner. If the context has a flipped-coordinate space—often the case on iOS—the origin is in the upper-left corner and the rectangle extends towards the lower-right corner.

Topics

Basic Geometric Properties

origin

A point that specifies the coordinates of the rectangle’s origin.

size

A size that specifies the height and width of the rectangle.

Checking Characteristics

CGRectIntersectsRect

Returns whether two rectangles intersect.

CGRectContainsPoint

Returns whether a rectangle contains a specified point.

CGRectContainsRect

Returns whether the first rectangle contains the second rectangle.

CGRectIsEmpty

Returns whether a rectangle has zero width or height, or is a null rectangle.

CGRectIsInfinite

Returns whether a rectangle is infinite.

CGRectIsNull

Returns whether the rectangle is equal to the null rectangle.

Alternate Representations

CGRectCreateDictionaryRepresentation

Returns a dictionary representation of the provided rectangle.

Comparing Rectangles

CGRectEqualToRect

Returns whether two rectangles are equal in size and position.

See Also

Geometric Data Types

CGPoint

A structure that contains a point in a two-dimensional coordinate system.

CGSize

A structure that contains width and height values.

CGVector

A structure that contains a two-dimensional vector.

CGAffineTransform

An affine transformation matrix for use in drawing 2D graphics.