Digging deeper into stacks
Stacks are an important part of SwiftUI and historically, the simplest stacks were among the first introduced features of the framework. With stacks, you can solve most of the commonly encountered layout issues, allowing you to recreate the commonly used screens in most applications. In this section, you will learn more about the various types of stacks available in SwiftUI and their differences, including the advantages and disadvantages of similar ones.
Overview of stacks
Stacks allow composing different views together. They basically serve the same purpose as stack views in UIKit. By grouping views vertically and horizontally, you can create much more complex views. Autolayout and its constraints are no longer needed to create views that will adapt to all screen sizes. You can achieve the same results by means of stacks. The simplest versions of stacks that we have already met are VStack
, HStack
, and ZStack
.
VStack
lays out the contained views...