Skip to content

Instantly share code, notes, and snippets.

@lucianoschillagi
Created October 2, 2024 13:37
Show Gist options
  • Save lucianoschillagi/9687451119814188a5529550d3d266ac to your computer and use it in GitHub Desktop.
Save lucianoschillagi/9687451119814188a5529550d3d266ac to your computer and use it in GitHub Desktop.
environment values (color scheme example)
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