Created
February 17, 2020 09:59
-
-
Save chriseidhof/b0f193b7b2cb4c4437185568ab6536cb to your computer and use it in GitHub Desktop.
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 MyView: View { | |
@State var text: String = "hello" | |
var body: some View { | |
TextField("title", text: $text) | |
} | |
} | |
struct ContentView: View { | |
@State var toggled: Bool = false | |
var body: some View { | |
let theTextView = MyView() | |
return VStack { | |
Toggle(isOn: $toggled, label: { Text("Toggle") }) | |
if toggled { | |
theTextView | |
} else { | |
theTextView.accentColor(.green) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment