SwiftUI Layout — Stacks, Spacer, List
Stacks
| Stack | Axis |
|---|---|
| ZStack | Depth — front and back |
| VStack | Vertical — up and down |
| HStack | Horizontal — left and right |
Original page had a screenshot here.
Original page had a screenshot here.
Spacer()
Adds maximum space between Views. Multiple Spacers spread out equally.
Original page had a screenshot here.
List
List(array-name) { variable in
// Insert functionality that will affect each item in the array.
// The variable is the name that you set for each item in the array.
// It's like a for loop
}
.listStyleUseful list modifiers
.listStyle(.plain)— list style.listRowSeparator(.hidden)— hides the separator lines.listRowBackground(Color(.brown).opacity(0.1))— change row background colour
See next
- SwiftUI-Styling — modifiers and colour
- Swift-Structures — Lists iterate over Identifiable structures