Instance Method

offset(x:y:)

Changes the relative position of this shape using the specified coordinates.

Declaration

func offset(x: CGFloat = 0, y: CGFloat = 0) -> OffsetShape<Rectangle>

Parameters

x

The horizontal amount, in points, by which you offset the shape. Negative numbers are to the left and positive numbers are to the right.

y

The vertical amount, in points, by which you offset the shape. Negative numbers are up and positive numbers are down.

Return Value

A shape offset by the specified amount.

Discussion

The following example shows two circles: One circle at its default position and another outlined with a stroke is overlaid on top and offset by 100 points to the left and 50 points below.

Circle()
.overlay(
    Circle()
    .offset(x: -100, y: 50)
    .stroke()
)