Skip to content

Instantly share code, notes, and snippets.

@chriseidhof
Created February 17, 2020 09:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chriseidhof/b0f193b7b2cb4c4437185568ab6536cb to your computer and use it in GitHub Desktop.
Save chriseidhof/b0f193b7b2cb4c4437185568ab6536cb to your computer and use it in GitHub Desktop.
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