SwiftUI ToolbarTitleMenu prevents navigation title truncation and pushes trailing toolbar items offscreen

2 days ago 3
ARTICLE AD BOX

I’m running into a layout issue with ToolbarTitleMenu in SwiftUI.

When I add a ToolbarTitleMenu to an inline navigation title, the title no longer truncates and instead takes priority over the trailing toolbar items, causing them to be truncated or moved into overflow. If I remove the title menu, the title truncates correctly and all trailing toolbar items remain visible.

import SwiftUI struct ContentView: View { var body: some View { NavigationStack { Text("Hello") .navigationTitle("Hellooooooooooooooooooooooooo") .toolbarTitleDisplayMode(.inline) .toolbar { ToolbarTitleMenu { } ToolbarItemGroup(placement: .topBarTrailing) { Image(systemName: "person") Image(systemName: "plus") Image(systemName: "pencil") } } } } }

With ToolbarTitleMenu present:

The navigation title does not truncate Trailing toolbar items get truncated/pushed offscreen

Without ToolbarTitleMenu:

The title truncates as expected All trailing toolbar items remain visible

How can I get SwiftUI to allow the navigation title to truncate while still using ToolbarTitleMenu, so that the toolbar items don't get pushed offscreen?

Read Entire Article