How to Use Stacks in SwiftUI

Mark van Wijnen
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

(More to come …)

Summary of the SwiftUI Layout System

  1. Parent proposes a size for child;
  2. Child chooses its own size;
  3. Parent places child in parent’s coordinate space;
  4. 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.

--

--

Mark van Wijnen
Mark van Wijnen

Written by Mark van Wijnen

macOS/iPadOS/iOS/watchOS/visionOS developer and SwiftUI enthousiast. “Stay Hungry, Stay Foolish!” — Steve Jobs

No responses yet