visibilityPriority(_:)
Defines the visibility priority for a toolbar item.
Declaration
func visibilityPriority(_ priority: ToolbarItemVisibilityPriority) -> some CustomizableToolbarContent
Parameters
- priority:
The visibility priority for this toolbar item.
Discussion
When toolbar space is limited, items with a lower priority move into the overflow menu before items with a higher priority. The default is automatic.
In the following example, PrimaryControl stays visible in the toolbar longer than SecondaryControl:
struct RootView: View {
var body: some View {
ContentView()
.toolbar {
ToolbarItem {
SecondaryControl()
}
ToolbarItem {
PrimaryControl()
}
.visibilityPriority(.high)
}
}
}