Instance Method

union(_:)

Returns the smallest rectangle that contains the two source rectangles.

Declaration

func union(_ r2: CGRect) -> CGRect

Parameters

r2

Another rectangle to be combined with this rectangle.

Return Value

The smallest rectangle that completely contains both of the source rectangles.

Discussion

Both rectangles are standardized prior to calculating the union. If either of the rectangles is a null rectangle, a copy of the other rectangle is returned (resulting in a null rectangle if both rectangles are null). Otherwise a rectangle that completely contains the source rectangles is returned.

See Also

Creating Derived Rectangles

var standardized: CGRect

Returns a rectangle with a positive width and height.

var integral: CGRect

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

func applying(CGAffineTransform) -> CGRect

Applies an affine transform to a rectangle.

func insetBy(dx: CGFloat, dy: CGFloat) -> CGRect

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

func offsetBy(dx: CGFloat, dy: CGFloat) -> CGRect

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

func intersection(CGRect) -> CGRect

Returns the intersection of two rectangles.

enum CGRectEdge

Coordinates that establish the edges of a rectangle.