Search code examples
swiftmacostoolbarswiftui-navigationview

MacOS Toolbar Space makes Items disappear despite sufficient space


I created a macOS App with a NavigationView and a Toolbar. Somehow next to my toolbarItem there is a lot of space.. So whenever I change the size of my apps window the toolbarItem disappears. Despite there is still a lot of space for my item. I did not find out how to reduce that space.. Can you help me?

var body: some View {
    NavigationView {
    }
       .toolbar(content: {
          ToolbarItem(placement: .navigation) {
             Image(systemName: "gearshape")
                .frame(height: 20)
          }
       })

enter image description here


Solution

  • I found the problem. The title is existing and just invisible. You can remove the title by adding .windowToolbarStyle(.unifiedCompact(showsTitle: false)) to the WindowGroup.