Contents

CGRectUnion(_:_:)

Returns the smallest rectangle that contains the two source rectangles.

Declaration

func CGRectUnion(_ r1: CGRect, _ r2: CGRect) -> CGRect

Parameters

  • r1:

    The first source rectangle.

  • r2:

    The second source 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

Modifying Rectangles