How to Use Alignments in SwiftUI — Custom Alignments

Mark van Wijnen
6 min readMar 11, 2022

This is the third part in the ‘SwiftUI Layout System’ series and the third part in the subseries about ‘How to Use Alignments in SwiftUI’. In this part we will talk about creating our own alignments.

The SwiftUI Layout System

(More to come …)

Custom Alignments

Let’s create an alignment of our own. Remember that an alignment only affects the position along the opposite axis of the stack. So on a HStack that would be the vertical axis and on a VStack that would be the horizontal axis.

For our example let us bring our crew back from part II.

As you will notice the images are aligned to the bottom of the container. However, the “visual” baseline of all the images is different. What we are after is some sort of floor for the crew to sit on.

--

--

Mark van Wijnen

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