Secondary Views

Secondary views are one of the more interesting layout tools available in SwiftUI, to understand them first we have to recall that views have fixed sizes. To recap the process: Parent proposes a size to its child. Child decides on its size. Parent positions the child within its bounds. Secondary views are useful because of […]

Combining Stacks

In the post about stacks we looked at the individual tools of horizontal, vertical, and z-axis stacks. When used on their own they’re useful ways of laying out views along a single axis. But when used together they’re a powerful way of creating even the most complicated layouts. Let’s continue our example of a character […]

Flexible Frames

In my first post I showed that in SwiftUI views have fixed sizes derived from the size of their content, but that that they can be flexible about what that fixed size is based on the size of their parent. The layout process looks like: Parent proposes a size to its child. Child decides on […]

Alignments

In this post I’ll discuss how alignments work in SwiftUI, building our understanding of how they function, and finishing by demonstrating how to create your own custom alignments for specific needs. Let’s start by taking a simple view that lays out horizontally three images of different heights: If you haven’t read my post about stacks, […]

Stacks

The three most important layout tools in your SwiftUI toolbox are the three kinds of stacks: horizontal, vertical, and z-axis (yes, there really is no good adjective for this one). These views are parents to multiple children, and in order to fully understand how these lay them out, you should first understand that views have […]

Views Have Fixed Sizes

One of the first things presented about SwiftUI is that its views determine their own sizes, and that those sizes are fixed. This is such a simple statement that it’s easy to move on quickly to get to the good stuff. This is a mistake, because it’s deceptive in its simplicity; this statement fundamentally changes […]