Overloads
2 ways to call compose().fixedSize(). Each is one SwiftUI overload, picked by the arguments you pass.
compose().fixedSize()@export(implementation) nonisolated func fixedSize() -> some ViewReturn value
A view that fixes this view at its ideal size.
Discussion
During the layout of the view hierarchy, each view proposes a size to each child view it contains. If the child view doesn't need a fixed size it can accept and conform to the size offered by the parent.
For example, a Text view placed in an explicitly sized frame wraps
and truncates its string to remain within its parent's bounds:
Text("A single line of text, too long to fit in a box.")
.frame(width: 200, height: 200)
.border(Color.gray)The fixedSize() modifier can be used to create a view that maintains
the ideal size of its children both dimensions:
Text("A single line of text, too long to fit in a box.")
.fixedSize()
.frame(width: 200, height: 200)
.border(Color.gray)This can result in the view exceeding the parent's bounds, which may or may not be the effect you want.
You can think of fixedSize() as the creation of a counter proposal
to the view size proposed to a view by its parent. The ideal size of a
view, and the specific effects of fixedSize() depends on the
particular view and how you have configured it.
To create a view that fixes the view's size in either the horizontal or
vertical dimensions, see View.fixedSize(horizontal:vertical:).
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.
- 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.
- gridCellColumnsTells a view that acts as a cell in a grid to span the specified number of columns.