Created
October 18, 2024 10:46
-
-
Save smsdm4/0fe3a48fc0c3625246cc9b2cbfcc91b5 to your computer and use it in GitHub Desktop.
SwiftUI @State 5
This file contains 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
struct ContentView: View { | |
@State private var isOn = false | |
var body: some View { | |
ToggleView(isOn: $isOn) | |
} | |
} | |
struct ToggleView: View { | |
@Binding var isOn: Bool | |
var body: some View { | |
Toggle(isOn: $isOn) { | |
Text("Toggle is \(isOn ? "ON" : "OFF")") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment