ToolbarItem: How to define which one should be hidden first if not enough space available

Viewed 65

I have implemented a toolbar in a SwiftUI app as follows:

 var body: some View {
   NavigationView.toolbar {
    ToolbarItem(placement: .automatic) {
      Text("Not essential - should be hidden *first*")
    }
    ToolbarItem(placement: .automatic) {
      Text("Essential - should be displayed whenever possible") // E.g. a search field
    }
  }
}

As it is, the items disappear starting from the right if the toolbar/window is too small to display all of them. Is there a way to manually define which ToolbarItem is hidden first if not enough space is available (e.g., so that the search field is visible whenever possible)?

Thank you for any help.

0 Answers
Related