SwiftUI: .fullscreenCover doesn't show .navigationTitle

Since NavigationView has been deprecated, what is the new way to show the navigation bar with a navigation title in SwiftUI? The code below doesn't show the nav bar:

var body: some View {
    Button {
        showFullscreenModal.toggle()
    } label: {
        Text("Test Fullscreen")
    }.sheet(isPresented: $showFullscreenModal) {
        Text("Modal content").navigationTitle("Modal title").toolbar {
            Button {
                self.showFullscreenModal = false
            } label: {
                Text("Cancel")
            }
        }
    }
}

Am I doing something wrong?

Accepted Reply

NavigationView was deprecated but was replaced by two new views: NavigationStack (single column) and NavigationSplitView (multiple columns).

In your case, you should just use a NavigationStack where you would have otherwise used a NavigationView.

  • That did the trick. So obvious now that it's pointed out to me 🥴

Add a Comment

Replies

NavigationView was deprecated but was replaced by two new views: NavigationStack (single column) and NavigationSplitView (multiple columns).

In your case, you should just use a NavigationStack where you would have otherwise used a NavigationView.

  • That did the trick. So obvious now that it's pointed out to me 🥴

Add a Comment