how to use 2 alerts in swiftui
enum ActiveAlert {
case first, second
}
struct ToggleView: View {
@State private var showAlert = false
@State private var activeAlert: ActiveAlert = .first
var body: some View {
Button(action: {
if Bool.random() {
self.activeAlert = .first
} else {
self.activeAlert = .second
}
self.showAlert = true
}) {
Text("Show random alert")
}
.alert(isPresented: $showAlert) {
switch activeAlert {
case .first:
return Alert(title: Text("First Alert"), message: Text("This is the first alert"))
case .second:
return Alert(title: Text("Second Alert"), message: Text("This is the second alert"))
}
}
}
}
Also in Swift:
- swift allow gesture recognizer over others
- coreData line of code
- swift programming language wikipedia
- meu eclipse não gera a implementação do mapstruct
- how to screen record swift stackoverflow
- swift increase int value
- IOS create UIAlertViewController programmatically
- swift constraint center vertically
- how to pass state variable in swiftui
- change font swiftui
- how to fetch data from server in swift
- stack view xcode
- how to remove subview siwft 5
- xcode disable a button
- swift subtract dates
- swift list
- sprite kitYourNextScene
- how to use 2 alerts in swiftui
- how do i get a string from a float swift to 1 decimal swift
- swift empty an array
- go to view controller programmatically swift
- UI API called on a background thread
- how to dismiss keyboard swiftui
- index string swift