We’ve arrived at day 92 of the 100 Days of SwiftUI! After finishing Flashzilla, we’ll be starting the final technique project of the course today and we’ll be looking at how SwiftUI handles layouts and geometry. Let’s dive in!
Layout and geometry introductions
In this technique project we’re going to explore how SwiftUI handles layout. Some of these things have been explained a little already, some of them you might have figured out yourself, but many more are things you might just have taken for granted to this point, so I hope a detailed exploration will really shed some light on how SwiftUI works.
Hacking with Swift, Paul Hudson (@twostraws)
How layout works in SwiftUI
A view happens in three simple steps, with a fourth step being performed behind the scenes. There are actually quite a few things to take note off, so be sure to go over Paul’s article and video on how layouts work.
Alignment and alignment guides
SwiftUI features multiple ways for us to align views. The simplest alignment option is to use the alignment
parameter of a frame()
modifier. This is something we’ve seen and used ourselves multiple times before. As for our other options, these are explained as well of course.
Wrap up
And that’s it for day 92 and the first day of our final technique project. We’ll continue tomorrow as we’ll look at absolute positioning and more theory about the GeometryReader
. Stay tuned for that!
100 Days of SwiftUI – Day 92