-
-
Save sujinnaljin/e06699969cb82500ed3a41fdf3b64d4f 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 ContentView: View { | |
@State var firstTitle = "firstTitle" | |
@State var secondTitle = "secondTitle" | |
@State var thirdTitle = "thirdTitle" | |
var body: some View { | |
VStack { | |
Text(firstTitle) | |
.background(.random) | |
Text(secondTitle) | |
.background(.random) | |
Text(thirdTitle) | |
.background(.random) | |
Button("Change first title") { | |
firstTitle = "hello world" | |
} | |
} | |
} | |
} | |
extension ShapeStyle where Self == Color { | |
static var random: Color { | |
Color( | |
red: .random(in: 0...1), | |
green: .random(in: 0...1), | |
blue: .random(in: 0...1) | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment