Laying Out Components
Laying out components
- swiftUI use three basic layout components
- VStack - arrange components in the vertical axis
- HStack - arrange components in the horizontal axis
- ZStack - arrange components along the vertical and horizontal axis.
- body view only returns a single view.
How the Stack view determine to show the display content
- Figure out its internal spacing and subtract that from the size proposed by its parent view.
- Divide the remaining space into equal parts.
- Process the size of its least flexible view.
- Divide the remaining unclaimed space by the unallocated space, and then repeat Step 2.
- The stack then aligns its content and chooses its own size to exactly enclose its children.