跳转至
Structure

DefaultNavigationViewStyle

The default navigation view style.

Declaration

struct DefaultNavigationViewStyle : NavigationViewStyle

Overview

Use this style with the navigationViewStyle(_:) modifier to set a NavigationView to use the default style given the context.

On iOS and Mac Catalyst, StackNavigationViewStyle is the default:

struct ExampleView: View {
    var destination: some View {
        Text("I'm stacked on the pancakes 📚")
            .navigationTitle("Second Screen")
    }

    var body: some View {
        NavigationView {
            NavigationLink(destination: destination) {
                Text("Stack the second screen! 🥞")
            }
        }
        .navigationViewStyle(DefaultNavigationViewStyle())
    }
}
A gif displaying an iOS default style NavigationView containing a NavigationLink that reads "Stack the second screen! 🥞" and causes a stacked text view reading "I'm stacked on the pancakes 📚" with the navigation title "Second Screen" to appear, covering the first view.

On macOS, DoubleColumnNavigationViewStyle is the default:

struct ExampleView: View {
    var destination: some View {
        Text("I just appeared in the middle 🤠")
            .navigationTitle("Second Screen")
    }

    var body: some View {
        NavigationView {
            NavigationLink(destination: destination) {
                Text("I'm in the sidebar ⬅️")
            }
        }
        .navigationViewStyle(DefaultNavigationViewStyle())
    }
}
A gif displaying a macOS default style NavigationView containing a NavigationLink in the left column that reads "I'm in the sidebar ⬅️" and causes a text view reading "I just appeared in the middle 🤠" with the navigation title "Second Screen" to appear in the right column.

Availability

iOS 13.0+

macOS 10.15+

tvOS 13.0+

watchOS 7.0+

Topics


Initializer

init() Creates a default navigation view style.