0Pricing
SwiftUI Academy · Lesson

ViewBuilder & Generic Containers

Accept arbitrary content with @ViewBuilder.

Containers That Hold Anything

VStack and List accept whatever views you nest inside them. You can build your own container that holds arbitrary content too. 📦

What @ViewBuilder Does

The @ViewBuilder attribute lets a closure list several views without commas or arrays. It is the magic behind stacks.

VStack {
    Text("One")
    Text("Two")
}

All lessons in this course

  1. Extracting Reusable Views
  2. Custom ViewModifiers
  3. ButtonStyle & LabelStyle
  4. ViewBuilder & Generic Containers
← Back to SwiftUI Academy