offset

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

Shape ModifieriOS 13.0+macOS 10.15+tvOS 13.0+watchOS 6.0+

Overloads

3 ways to call compose().offset(). Each is one SwiftUI overload, picked by the arguments you pass.

React
compose().offset(offset: CGSize)
Swift
nonisolated func offset(_ offset: CGSize) -> OffsetShape<Self>

Parameters

  • offset*CGSize

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

Return value

A shape offset by the specified amount.

Discussion

The following example renders two circles. It places one circle at its default position. The second circle is outlined with a stroke, positioned on top of the first circle and offset by 100 points to the left and 50 points below.

Circle()
.overlay(
    Circle()
    .offset(CGSize(width: -100, height: 50))
    .stroke()
)

See also

More in Shape modifiers.