0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

画面遷移ボタン作成

Last updated at Posted at 2023-09-01

勉強中のため間違っていましたら訂正お願いします。

検証環境は以下
・Xcode 14.3.1

#画面遷移ボタン作成方法

NavigationStack{
            VStack{
                Text("画面")
            }
            .toolbar{
                ToolbarItem(placement: .navigationBarTrailing){
                    NavigationLink{
                        //画面遷移した時にとぶページ
                        SettingView()
                    }label:{
                        //ボタンの名前
                        Text("ボタン")
                    }
                }

完成品がこちら!!
スクリーンショット 2023-09-01 21.27.28.png

『.toolber』は『NavigationStack』でのボタン配置を指示するモディファイアです。
『ToolbarItem』でボタンとボタンの配置を指示します。
『ToolbarItem』の引数であるplacementにボタンを配置する位置を指定します。

placement=配置

色々なボタン配置

.toolber{
    ToolberItem(placement: 配置するアイテム){
        配置するアイテム
    }
}

①配置するアイテには自分が配置したいボタンの場所を記入します。

.bottomBer...アイテムを下部のツールバーに配置
スクリーンショット 2023-09-01 21.42.14.png

.navigationBarLeading...アイテムを左端のツールバーに配置
スクリーンショット 2023-09-01 21.45.43.png

.automatic...周囲のコンテンツの状況からアイテムを自動的に配置
.navigation...ユーザーがコンテキスト間を移動できるナビゲーションアクションを配置

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?