Offsets the view by the horizontal and vertical distances in the given size.
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
size
The distance to offset this view.
Return Value
A view that offsets this view by size
.
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(CGSize(width: 50, height: 10))
.border(Color.gray)