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

navigationBarItems(trailing:)

Configures the navigation bar items for this view. ナビゲーションバー項目をこのビューに対して構成設定します。

Declaration 宣言

func navigationBarItems<T>(trailing: T) -> some View where T : View

Parameters パラメータ

trailing

A view shown on the trailing edge of the title. タイトルの末端で示されるビュー。

Discussion 議論

Use navigationBarItems(trailing:) to add navigation bar items to the trailing edge of the navigation bar for this view. This modifier only takes effect when this view is inside of and visible within a NavigationView.

The example below adds buttons to the trailing edge of the button area of the navigation view:


struct FlavorView: View {
    var body: some View {
        NavigationView {
            List {
                Text("Chocolate")
                Text("Vanilla")
                Text("Strawberry")
            }
            .navigationBarTitle(Text("Today‘s Flavors"))
            .navigationBarItems(trailing:
                HStack {
                    Button("Hours") {
                        print("Hours tapped!")
                    }


                    Button("Help") {
                        print("Help tapped!")
                    }
                }
            )
        }
    }
}

See Also 参照

Auxiliary View Modifiers