
This video is only available to subscribers. Start a subscription today to get access to this and 469 other videos.
SwiftUI Environment
Episode
#440
|
9 minutes
| published on
May 18, 2020
| Uses Xcode-11.4, Swift-5.2
Subscribers Only
It can be cumbersome to pass values from parent to child view to configure something. For instance, setting a font for many Text views inside of a VStack. Luckily there is a .font() modifier that can do this for you. How does it work? It sets a value in the Environment using an EnvironmentKey. In this episode we will learn how to leverage the SwiftUI environment to pass values to descendent views, regardless of their depth from where it is set.