3

What is the difference between ①navigationBarTitleDisplayMode and ②toolbarTitleDisplayMode when using them with SwiftUI’s navigationTitle?

It appears that .inlineLarge only works with the latter (②), and the toolbarTitleMenu option for adding a Menu to the title also adopts the name of the latter (②), so I thought that Apple might be planning to transition from ① to ②. However, the API name for navigationTitle has remained the same, and no toolbarTitle API exists.

I am curious why Apple maintains these two APIs without deprecating one. If anyone has any insights or speculations, I would appreciate your thoughts. Is there a difference between these two codes that I may have overlooked?

struct ContentView: View {
    var body: some View {
        NavigationStack {
            Text("Hello, world!")
                .navigationTitle("Hello")
            //(1).navigationBarTitleDisplayMode(.inline)
            //(2).toolbarTitleDisplayMode(.inlineLarge)
        }
    }
}

Additionally, I wonder if this is related to the recent deprecation of navigationBarTitle.

1 Answer 1

1

Why Apple has these two APIs:

navigationBar is iOS/iPad only and toolbar works on macOS (as well as both iOS/iPad). toolbar in SwiftUI is the way to go forward as navigationBar is being deprecated and toolbar works for all target development.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.