axisBehavior(_:)
The bar axis behavior of the toolbar item.
Declaration
nonisolated func axisBehavior(_ behavior: ToolbarItemAxisBehavior) -> some ToolbarContent
Parameters
- behavior:
The axis behavior of the item.
Discussion
Use this modifier to control which bar axes a toolbar item can appear in.
The following example restricts an item to the horizontal axis. The item can only appear in a horizontal bar.
.toolbar {
ToolbarItem(placement: .primaryAction) {
Toggle(isOn: $isOn) { ... }
}
.axisBehavior(.horizontalOnly)
}If both horizontal & vertical bars are present and the item is .verticalPreferred, the system prefers placing the item in the vertical bar.