Episode #439

Sizing Things Equally in SwiftUI

9 minutes
Published on May 15, 2020

This video is only available to subscribers. Get access to this video and 572 others.

Using Preferences we can communicate data, such as the actual size of a view, to any ancestor view. By taking advantage of the reduce function required by the PreferenceKey protocol, we can combine multiple values in whatever way suits our needs. In this episode we will use this technique to size a bunch of sibling views equally by collecting the biggest width and then pushing this value down to subviews with some parent state.

This episode uses Xcode 11.4, Swift 5.2.