Declaration
compose().gridCellUnsizedAxes(axes: SwiftUI.AxisSet)nonisolated func gridCellUnsizedAxes(_ axes: Axis.Set) -> some ViewParameters
axes*SwiftUI.AxisSet
Return value
A view that doesn't ask an enclosing grid for extra size in one or more axes.
Discussion
Use this modifier to prevent a flexible view from taking more space
on the specified axes than the other cells in a row or column require.
For example, consider the following Grid that places a Divider
between two rows of content:
Grid {
GridRow {
Text("Hello")
Image(systemName: "globe")
}
Divider()
GridRow {
Image(systemName: "hand.wave")
Text("World")
}
}The text and images all have ideal widths for their content. However, because a divider takes as much space as its parent offers, the grid fills the width of the display, expanding all the other cells to match:
You can prevent the grid from giving the divider more width than
the other cells require by adding the modifier with the
Axis.horizontal parameter:
Divider()
.gridCellUnsizedAxes(.horizontal)This restores the grid to the width that it would have without the divider:
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.