Views & Modifiers

June 02, 2026 1 min read

SwiftUI UIs are built from small views (Text, Image, Button) styled with modifiers — methods that return a new, modified view.

Chaining modifiers

Text("Welcome")
    .font(.headline)
    .foregroundColor(.white)
    .padding()
    .background(Color.blue)
    .cornerRadius(10)

Order matters: .padding().background() differs from .background().padding().

Common views

  • Text, Image, Label for content.
  • Button, Toggle, TextField for interaction.
  • Spacer and Divider for layout.

Summary

Build UI from small views and shape them with chained modifiers — remembering that modifier order changes the result.