0
1

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 3 years have passed since last update.

【SwiftUI】ダイアログ表示

Last updated at Posted at 2021-09-29

アラートを使ってダイアログ表示させます。
最も汎用的に使えるソースコードを記載しています。

プレビュー

ソースコード

    @State private var showAlert = false
    var body: some View {
        Button("ダイアログを表示します") {
            showAlert = true
        }
        .alert(isPresented: $showAlert) {
            Alert(
                title: Text("タイトル"),
                message: Text("サブタイトル"),
                primaryButton: .default(
                    Text("OK"),
                    action: {} //OKボタンの処理
                ),
                secondaryButton: .destructive(
                    Text("キャンセル"),
                    action: {} //キャンセルボタンの処理
                )
            )
        }
    }
0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?