SwiftUI Environment Property Wrapper
Dec 27, 2021
We can get system-wide settings like color scheme(light or dark), size class, device locale using @Environment property wrapper. The full list for the values/settings we can access are here: https://developer.apple.com/documentation/swiftui/environmentvalues
Let’s see an example:
Here, we have two environment values: colorScheme and verticalSizeClass. We change text color according to colorScheme and we switch between VStack and HStack according to verticalSizeClass.