1 Matching Annotations
  1. Nov 2020
    1. What’s a Stack? A stack is a collection of SwiftUI views that are grouped together. You can use 3 kinds of stacks with SwiftUI: VStack, a vertical stack, which shows views in a top-to-bottom list HStack, a horizontal stack, which shows views in a left-to-right list ZStack, a depth-based stack, which shows views in a back-to-front list Here’s a visual example: <img src="https://learnappmaking.com/wp-content/uploads/2020/08/swiftui-stacks-diagram.jpg" width="1125" height="450" alt="Diagram of HStack, VStack, ZStack in SwiftUI"> You can compare stacks in SwiftUI with UIStackView in UIKit. Stacks are static, so they’re different from List and table views, for example. Like other SwiftUI views, stacks can contain a maximum of 10 subviews. You can, of course, combine VStacks, HStacks and ZStacks to create complex User Interfaces.