Instance Method


Offset the view by the horizontal and vertical amount specified in the offset parameter.


func offset(_ offset: CGSize) -> some View



The distance to offset this view.

Return Value

A view that offsets this view by offset.


Use offset(_:) to to shift the displayed contents by the amount specified in the offset parameter.

The original dimensions of the view are not changed by offsetting the contents; in the example below the gray border drawn by this view surrounds the original position of the text:

Text("Offset by passing CGSize()")
    .offset(CGSize(width: 20, height: 25))
A screenshot showing a view that offset from its original position a CGPoint to specify the x and y offset.

See Also

Positioning a View

func position(CGPoint) -> View

Positions the center of this view at the specified point in its parent‘s coordinate space.

func position(x: CGFloat, y: CGFloat) -> View

Positions the center of this view at the specified coordinates in its parent’s coordinate space.

func offset(x: CGFloat, y: CGFloat) -> View

Offset this view by the specified horizontal and vertical distances.

func edgesIgnoringSafeArea(Edge.Set) -> View

Change the view’s proposed area to extend outside the screen’s safe areas.

func coordinateSpace<T>(name: T) -> View

Assigns a name to the view’s coordinate space, so other code can operate on dimensions like points and sizes relative to the named space.