Hi, I'm starting to learn swiftUI and, somewhere in the last few weeks, I remember watching an old video (I think from WWDC) the described the algorithm that swiftUI uses for laying out views.
Now I'd like to review that information, but search as I might, I can't find it again. Does anyone know what that video that might be, or better yet, please suggest a superior resource. I'm struggling to control how siblings in an HStack get stretched (FWIW a TextField next to a Stepper), and need more insight into the algorithm.
Thanks!
Oh, I think I’ve found it. There’s lots of good layout information in “Building Custom Views with SwiftUI” from WWDC 2019.
Additionally, for future me, when I’m looking to solve layout problems, I would say that topics to be familiar with are:
- layoutPriority
- fixedSize
- Spacer
- GeometryReader
- alignmentGuide
- PreferenceKey protocol
The last two are pretty advanced and obscure mechanisms, but sometimes that’s what’s needed!