← iOS Development (Swift) learning path
iOS Development (Swift) · Module 5 of 10

SwiftUI views and layout

Build interfaces with SwiftUI views and stacks.

📖 Key ideas

  1. A view is a struct conforming to View with a body.
  2. Stacks: VStack, HStack, ZStack.
  3. Modifiers: .padding(), .font(.title), .foregroundStyle(.blue).
  4. Common views: Text, Image, Button, List, Spacer.
  5. #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