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.

Nothing yet...

blog comments powered by Disqus