How to Use Stacks in SwiftUI
16 min readOct 19, 2020
This is the second part in the ‘SwiftUI Layout System’ series in which we will learn everything you need to know about Stacks. What they are, how they work and find out about its layout process.
The SwiftUI Layout System
- How to Use the SwiftUI Layout System
- How to Use Stacks in SwiftUI
- How to Use Alignments in SwiftUI
(More to come …)
Summary of the SwiftUI Layout System
- Parent proposes a size for child;
- Child chooses its own size;
- Parent places child in parent’s coordinate space;
- SwiftUI rounds coordinates to nearest pixel.
For more detailed information about the SwiftUI layout system I strongly suggest you read my previous story: ‘The Basics of the SwiftUI Layout System’.
What Are Stacks?
Stacks are layout tools provided by SwiftUI to help us arrange the children in a view.