Search code examples
swiftswiftuiswiftui-navigationview

NavigationView bar material invisible on iOS 15


On iOS 15, an app with a NavigationView with .inline mode no longer shows the blurry material color you would see for the navigation bar.

Example code:

struct ContentView: View {
    var body: some View {
        NavigationView {
            ZStack {
                Color.red.ignoresSafeArea()
                
                Text("Content")
            }
            .navigationBarTitleDisplayMode(.inline)
        }
    }
}

Comparison:

iOS 14.4 iOS 15
iOS 14.4 result iOS 15 result

How can I fix this to keep the iOS 14 behaviour?


Solution

  • In iOS 16+ you can solve this using .toolbarBackground

    NavigationStack {
      Text("Hello")
          .toolbarBackground(.visible, for: .navigationBar)
          .toolbarBackground(.ultraThinMaterial, for: .navigationBar)
    }