Instance Method

divided(atDistance:from:)

Creates two rectangles by dividing the original rectangle.

Declaration

func divided(atDistance: CGFloat, from fromEdge: CGRectEdge) -> (slice: CGRect, remainder: CGRect)

Parameters

atDistance

A distance from the rectangle side specified in the fromEdge parameter, defining the line along which to divide the rectangle.

fromEdge

The side of the rectangle from which to measure the atDistance parameter, defining the line along which to divide the rectangle.

Return Value

A tuple containing two rectangles:

slice: The component rectangle nearest the edge of the original rectangle specified in the fromEdge parameter, with width equal to the atDistance parameter.

remainder: The component rectangle equal to the remaining area of the original rectangle not included in the slice rectangle.

Discussion

Together the fromEdge and atDistance parameters define a line (parallel to the specified edge of the rectangle and at the specified distance from that edge) that divides the rectangle into two component rectangles.

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 union(CGRect) -> CGRect

Returns the smallest rectangle that contains the two source rectangles.

func intersection(CGRect) -> CGRect

Returns the intersection of two rectangles.

enum CGRectEdge

Coordinates that establish the edges of a 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