Fixes the view at its ideal size.
SDKs
- iOS 13.0+
- macOS 10.15+
- Mac Catalyst 13.0+
- tvOS 13.0+
- Xcode 11.0+
Framework
- Swift
UI
Declaration
func fixedSize() -> some View
Return Value
A view that fixes this view at its ideal size in the dimensions given in fixed
.
Discussion
This example shows the effect of fixed
on a text view that is wider than its parent, preserving the ideal, untruncated width of the text view.
Text("A single line of text, too long to fit in a box.")
.fixedSize()
.frame(width: 200, height: 200)
.border(Color.gray)
Without the call to fixed
, the text view has its width set by its parent, which truncates the line of text.
Text("A single line of text, too long to fit in a box.")
.frame(width: 200, height: 200)
.border(Color.gray)