SwiftUI Views & Layouts

Jun 20 2024 · Swift 5.10, iOS 17.4, Xcode 15.3

Lesson 03: Building Views

Demo 1

Episode complete

Play next episode

Next

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

To use AnyLayout, you’ll reuse most of the code of the current iteration. The difference is that instead of using the vertical and horizontal size classes and landscapeIsCompact to switch between VStack and HStack, you’ll define the layout of AnyLayout and it will switch between the two for you.

var layout: AnyLayout {
  landscapeIsCompact ?
    AnyLayout(HStackLayout(spacing: 16)) :
    AnyLayout(VStackLayout(spacing: 16))
}
layout {
  ColorCardView(color: color)

  RGBSlidersStackView(
    color: $color,
    red: $red,
    green: $green,
    blue: $blue
  )
}
.padding()
See forum comments
Cinema mode Download course materials from Github
Previous: Instruction 1 Next: Instruction 2