NavigationView List Large Title doesn't work with background color [duplicate]

20 hours ago 1
ARTICLE AD BOX

I have a very weird issue that if I have a List inside a NavigationView, the title disappears. But this only happens if I have set a background color. Here is the code that Works.

import SwiftUI struct ContentView: View { var body: some View { NavigationView { ZStack { Text("World") } .navigationTitle("Hello") .toolbarBackground(Color.pink.opacity(1),for: .navigationBar) .toolbarBackground(.visible, for: .navigationBar) } } } #Preview { ContentView() }

An image showing the title appearing

However, as soon as I replace the ZStack with a List, it doesn't anymore:

import SwiftUI struct ContentView: View { var body: some View { NavigationView { List { Text("World") } .navigationTitle("Hello") .toolbarBackground(Color.pink.opacity(1),for: .navigationBar) .toolbarBackground(.visible, for: .navigationBar) } } } #Preview { ContentView() }

Image showing a title appearing

Any idea why it doesn't work and what do I need to do to get the large title to work while also retaining the ability to have a background color?

Read Entire Article