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?

SwiftUI 入力可能なアラートの実装

Posted at

文字入力可能なアラートの実装例です。

AlertText.swift
struct AlertText: View {

    @State private var inputText: String = ""
    @State private var showAlert: Bool = false

    var body: some View {
        ZStack {
            Button("アラート表示") {
                self.inputText = ""
                self.showAlert = true
            }
            .alert("入力してください", isPresented: $showAlert) {
                TextField("入力", text: $inputText)
                Button("完了") {}
                Button("キャンセル", role: .cancel, action: {})
            }
        }
    }
}

この様になります。

Simulator Screenshot - iPhone 16 Pro - 2025-03-23 at 17.59.46.png

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?