HomeiOS DevelopmentSwiftUI ToolbarTitleMenu prevents navigation title truncation and pushes trailing toolbar objects offscreen

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


I’m operating right into a structure situation with ToolbarTitleMenu in SwiftUI.

After I add a ToolbarTitleMenu to an inline navigation title, the title not truncates and as a substitute takes precedence over the trailing toolbar objects, inflicting them to be truncated or moved into overflow. If I take away the title menu, the title truncates appropriately and all trailing toolbar objects stay seen.

import SwiftUI

struct ContentView: View {
    var physique: some View {
        NavigationStack {
            Textual content("Good day")
                .navigationTitle("Hellooooooooooooooooooooooooo")
                .toolbarTitleDisplayMode(.inline)
                .toolbar {
                    ToolbarTitleMenu { }

                    ToolbarItemGroup(placement: .topBarTrailing) {
                        Picture(systemName: "particular person")
                        Picture(systemName: "plus")
                        Picture(systemName: "pencil")
                    }
                }
        }
    }
}
  • With ToolbarTitleMenu current:

    • The navigation title doesn’t truncate
    • Trailing toolbar objects get truncated/pushed offscreen
    • SwiftUI ToolbarTitleMenu prevents navigation title truncation and pushes trailing toolbar objects offscreen
  • With out ToolbarTitleMenu:

    • The title truncates as anticipated
    • All trailing toolbar objects stay seen

How can I get SwiftUI to permit the navigation title to truncate whereas nonetheless utilizing ToolbarTitleMenu, in order that the toolbar objects do not get pushed offscreen?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments