Instance Method

contains(_:)

Returns whether a rectangle contains a specified point.

Declaration

func contains(_ point: CGPoint) -> Bool

Parameters

rect

The rectangle to examine.

point

The point to examine.

Return Value

true if the rectangle is not null or empty and the point is located within the rectangle; otherwise, false.

Discussion

A point is considered inside the rectangle if its coordinates lie inside the rectangle or on the minimum X or minimum Y edge.

See Also

Checking Characteristics

func intersects(CGRect) -> Bool

Returns whether two rectangles intersect.

func contains(CGRect) -> Bool

Returns whether the first rectangle contains the second rectangle.

var isEmpty: Bool

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

var isInfinite: Bool

Returns whether a rectangle is infinite.

var isNull: Bool

Returns whether the rectangle is equal to the null rectangle.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software