← iOS Development (Swift) learning pathiOS Development (Swift) · Module 5 of 10
SwiftUI views and layout
Build interfaces with SwiftUI views and stacks.
📖 Key ideas
- A view is a struct conforming to View with a body.
- Stacks: VStack, HStack, ZStack.
- Modifiers: .padding(), .font(.title), .foregroundStyle(.blue).
- Common views: Text, Image, Button, List, Spacer.
- #Preview shows live previews in Xcode.
💡 Real-life example: SwiftUI stacks are shelves: vertical shelves, horizontal shelves and layers on top of each other.
VStackVertical stack
HStackHorizontal stack
ZStackLayered stack
ModifierMethod that changes a view