Created
October 2, 2024 13:37
-
-
Save lucianoschillagi/9687451119814188a5529550d3d266ac to your computer and use it in GitHub Desktop.
environment values (color scheme example)
This file contains hidden or 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
| import SwiftUI | |
| struct ContentView: View { | |
| // @Environment: A property wrapper that reads a value from a view’s environment. | |
| // Access the 'colorScheme' from the environment | |
| // The current 'colorScheme' used by the system. | |
| @Environment(\.colorScheme) var colorScheme | |
| var body: some View { | |
| Text("The current Color Scheme is \(colorScheme).").bold() | |
| } | |
| } | |
| // See full list of environment values here → https://developer.apple.com/documentation/swiftui/environmentvalues |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment