Skip to content

Instantly share code, notes, and snippets.

@takoikatakotako
Created October 24, 2024 01:48
Show Gist options
  • Select an option

  • Save takoikatakotako/6f4118edd5067ee30b5bab5fc5286ec3 to your computer and use it in GitHub Desktop.

Select an option

Save takoikatakotako/6f4118edd5067ee30b5bab5fc5286ec3 to your computer and use it in GitHub Desktop.
Alertを表示する
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