.toggle
Last updated
Was this helpful?
Last updated
Was this helpful?
Flips True/False
Example 1
struct ContentView: View {
@State private var useRedText = false
var body: some View {
Button("Hello World") {
// flip the Boolean between true and false
useRedText.toggle()
}
.foregroundColor(useRedText ? .red : .blue)
}
}