Created
October 24, 2024 01:48
-
-
Save takoikatakotako/6f4118edd5067ee30b5bab5fc5286ec3 to your computer and use it in GitHub Desktop.
Alertを表示する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| struct ContentView: View { | |
| @State var showingAlert = false | |
| var body: some View { | |
| VStack { | |
| Button { | |
| showingAlert = true | |
| } label: { | |
| Text("Show Alert") | |
| } | |
| } | |
| .alert("Alert Title", isPresented: $showingAlert) { | |
| Button("Done", role: .none) { | |
| print("Done") | |
| } | |
| Button("Cancel", role: .cancel) { | |
| print("Cancel") | |
| } | |
| } message: { | |
| Text("Message") | |
| } | |
| } | |
| } | |
| #Preview { | |
| ContentView() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment