Instance Method インスタンスメソッド

navigationViewStyle(_:)

Sets the style for navigation views within this view. このビュー内のナビゲーションビューそれらに対してスタイルを設定します。

Declaration 宣言

func navigationViewStyle<S>(_ style: S) -> some View where S : NavigationViewStyle

Discussion 議論

Use this modifier to change the appearance and behavior of navigation views. For example, by default, navigation views appear with multiple columns in wider environments, like iPad in landscape orientation:

A screenshot of an iPad in landscape orientation mode showing a

You can apply the stack style to force single-column stack navigation in these environments:


NavigationView {
    List {
        NavigationLink("Purple", destination: ColorDetail(color: .purple))
        NavigationLink("Pink", destination: ColorDetail(color: .pink))
        NavigationLink("Orange", destination: ColorDetail(color: .orange))
    }
    .navigationTitle("Colors")


    Text("Select a Color") // A placeholder to show before selection.
}
.navigationViewStyle(.stack)

A screenshot of an iPad in landscape orientation mode showing a