Home > OS >  How to force navigation bar to show background in SwiftUI?
How to force navigation bar to show background in SwiftUI?

Time:01-29

I have the following (on iOS 16):

NavigationStack
{
    Form
    {
        ....
    }
}
.navigationTitle("Hello")
.navigationBarTitleDisplayMode(.inline)

The navigation bar background only appears when scrolling the Form upwards.

How can I make sure that the background is always showing?

CodePudding user response:

use this to always show the background:

.toolbarBackground(.visible, for: .navigationBar)

and this to style it:

.toolbarBackground(.red, for: .navigationBar)
  • Related