Search code examples
iosswiftuiswiftui-navigationstack

NavigationStack title loads inline instead of large when sheet is presented


One of my views loads in a bottom sheet. It has its own NavigationStack with a title. Problem is that whenever the view is loaded, the title (set on ".automatic") always loads ".inline" instead.

The same happens even if I force the .navigationBarTitleDisplayMode to ".large". The title only goes to ".large" if I scroll the view.

Tried to look into this question but it's about adding the .navigationViewStyle which will soon be deprecated (and applies to NavgationView, not NavigationStack). Is there a way to make the title load .large?

My code for the view inside the bottom sheet:

NavigationStack {
    Form {
        // some code
    }

    .navigationTitle("Title")
    .navigationBarTitleDisplayMode(.large)
}

Solution

  • The accepted answer doesn't work for me. Here's a fix that works on iOS 17. Use NavigationView instead of NavigationStack.

    /* NavigationStack { DON'T USE THIS */
    NavigationView {
    
        Form {
            // some code
        }
    
        .navigationTitle("Title")
        .navigationBarTitleDisplayMode(.large)
    }
    

    Just note, XCode says "NavigationView will be deprecated in a future version of iOS".