SwiftUI: Layout & Interfaces

Nov 18 2021 · Swift 5.5, iOS 15, Xcode 13

Part 1: Dynamic View Layout

02. Lazy Stacks

Episode complete

Play next episode

Next
About this episode

Leave a rating/review

See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 01. Introduction Next episode: 03. ScrollViewReader

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Notes: 02. Lazy Stacks

Update Notes: This course was originally recorded in 2020. It has been reviewed and all content and materials updated as of October 2021.

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

The first of SwiftUI’s “lazy” views that we’ll be going over are the Stacks.


    ForEach(/*@START_MENU_TOKEN@*/0 ..< 5/*@END_MENU_TOKEN@*/) { item in
      Text(
        formatter.string(from: Date())
      )
    }
     var body: some View {
    VStack {
      let formatter: DateFormatter = {
        let formatter = DateFormatter()
        formatter.timeStyle = .medium
        return formatter
      } ()

      ForEach(/*@START_MENU_TOKEN@*/0 ..< 5/*@END_MENU_TOKEN@*/) { item in
        Text(
          formatter.string(from: Date())
        )
      }
    }
  }
ForEach(Genre.list) { genre in
          formatter.string(from: Date())
        )

        genre.subgenres.randomElement()!.view
      }
ForEach(Genre.list.flatMap(\.subgenres)) { subgenre in
subgenre.view
ForEach(Genre.list.prefix(2).flatMap(\.subgenres)) { subgenre in
LazyVStack {
Genre.list.flatMap
  var body: some View {
//    ScrollView {
      List {
        let formatter: DateFormatter = {
          let formatter = DateFormatter()
          formatter.timeStyle = .medium
          return formatter
        } ()

        ForEach(Genre.list.flatMap(\.subgenres)) { subgenre in
          Text(
            formatter.string(from: Date())
          )

          subgenre.view
        }
      }
//    }
  }

   ScrollView(.horizontal)
LazyHStack