SwiftUI Environment Property Wrapper

--

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.

--

--

No responses yet