View ModifieriOS 13.0+macOS 10.15+tvOS 13.0+watchOS 6.0+
Overloads
2 ways to call compose().offset(). Each is one SwiftUI overload, picked by the arguments you pass.
compose().offset(offset: CGSize)nonisolated func offset(_ offset: CGSize) -> some ViewParameters
offset*CGSizeThe distance to offset this view.
Return value
A view that offsets this view by offset.
Discussion
Use offset(_:) to shift the displayed contents by the amount
specified in the offset parameter.
The original dimensions of the view aren't 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()")
.border(Color.green)
.offset(CGSize(width: 20, height: 25))
.border(Color.gray)See also
More in Layout.
- alignmentGuideSets the view's vertical alignment.
- aspectRatioConstrains this view's dimensions to the specified aspect ratio.
- containerCornerOffsetAdjusts the view's layout to avoid the container view's corner insets for the specified edges.
- containerRelativeFramePositions this view within an invisible frame with a size relative to the nearest container.
- controlSizeSets the size for controls within this view.
- defaultScrollAnchorAssociates an anchor to control which part of the scroll view's content should be rendered by default.
- dynamicTypeSizeSets the Dynamic Type size within the view to the given value.
- fixedSizeFixes this view at its ideal size.
- flipsForRightToLeftLayoutDirectionSets whether this view mirrors its contents horizontally when the layout direction is right-to-left.
- framePositions this view within an invisible frame.
- geometryGroupIsolates the geometry (e.g. position and size) of the view from its parent view.
- gridCellAnchorSpecifies a custom alignment anchor for a view that acts as a grid cell.