Created
October 5, 2020 16:06
-
-
Save wizard1066/03aba262b1ecb63f3a4293c0f6ba6977 to your computer and use it in GitHub Desktop.
variable2.swift
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 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