MΓ³dulo 04 Β· SwiftUI: First Screens β LecciΓ³n 3 de 4 Β· ~11 min
Stacks: Laying Things Out
Three stacks, all of layout
One view per screen won't get you far. SwiftUI's layout system is built on three containers, each just a view that arranges its children:
VStackβ stacks children vertically, top to bottom.HStackβ lines children up horizontally, left to right.ZStackβ layers children on top of each other, back to front (first child is at the back).
You compose them by nesting: a screen is a VStack of rows, each row an HStack of an icon and some text. PawWalk's whole Home screen is stacks inside stacks.
Both VStack and HStack take two optional parameters: alignment (how children line up on the cross axis β e.g. .leading for left-aligned in a VStack) and spacing (the gap between children, in points).