Lesson 03 · iOS with Swift & SwiftUI
iOS: SwiftUI Views & Layout
The SwiftUI view system: the View protocol and body, Text, Image and Button, the three stacks, modifiers as the layout engine, sizing with frame and layout priority, ScrollView, List with ForEach and Identifiable, and NavigationStack-powered list-to-detail navigation.
Prerequisites: iOS: Xcode & Your First App
Learning objectives
By the end of this lesson, you will be able to:
- Conform to the View protocol with a body that composes Text, Image(systemName:) and Button views
- Choose and configure VStack, HStack and ZStack with explicit spacing and alignment, using Spacer for flexible gaps
- Predict a view's appearance from modifier order - padding before background versus after - and control sizing with frame and layoutPriority
- Build scrolling content with ScrollView and List, driving rows with ForEach over Identifiable data
- Wire list-to-detail navigation with NavigationStack, navigationDestination and NavigationLink, passing data to the destination