Skip to content

Instantly share code, notes, and snippets.

@wizard1066
Created October 5, 2020 16:06
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save wizard1066/03aba262b1ecb63f3a4293c0f6ba6977 to your computer and use it in GitHub Desktop.
variable2.swift
struct ContentView: View {
@State var greeting:Words = .init(word: "Hello, World!", wordColor: Color.blue)
var body: some View {
SwiftUIViewB(bonjour: $greeting)
}
}
struct Words {
var word: String = ""
var wordColor: Color = Color.red
}
struct SwiftUIViewB: View {
@Binding var bonjour: Words
var body: some View {
Text(bonjour.word)
.foregroundColor(bonjour.wordColor)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment