Offsets the view by the specified horizontal and vertical distances.
SDKs
- iOS 13.0+
- macOS 10.15+
- Mac Catalyst 13.0+
- tvOS 13.0+
- watchOS 6.0+
- Xcode 11.0+
Framework
- Swift
UI
Declaration
Parameters
x
The horizontal distance to offset this view.
y
The vertical distance to offset this view.
Return Value
A view that offsets this view by x
and y
.
Discussion
The original dimensions of the view are considered to be unchanged by offsetting the contents. For example, the gray border drawn by this view surrounds the original position of the text:
Text("Hello world!")
.font(.title)
.offset(x: 50, y: 10)
.border(Color.gray)