SwiftUI Fundamentals

Feb 28 2023 · Swift 5.7, macOS Venture 13.1, Xcode 14.2

Part 1: SwiftUI Views

09. Challenge: Stacks & ForEach

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: 08. Repeat Views with ForEach & Lists Next episode: 10. Introduction

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.

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

This is your last challenge in this part!

VStack(alignment: .leading) {
  Text("Cupertino")
    .font(.title3)
  Text("63°")
    .font(.largeTitle)
}
VStack(alignment: .trailing) {
  Image(systemName: "sun.max.fill")
    .renderingMode(.original)
  
  Text("Sunny")
  Text("H:68° L:42°")
}
HStack(alignment: .lastTextBaseline) {
  VStack(alignment: .leading) { }

  Spacer()

  VStack(alignment: .trailing) { }
}
struct CurrentConditions: View {
...
}
VStack {
  Text(weather.hourlyForecast[0].hour)
  
  weather.hourlyForecast[0].conditions
    .renderingMode(.original)
    .frame(height: 50)
  
  Text(weather.hourlyForecast[0].temperature)
}
struct HourlyForecast: View {
  let forecast: Weather.Forecast
  
  var body: some View {
    VStack {
      Text(forecast.hour)
      
      forecast.conditions
        .renderingMode(.original)
        .frame(height: 50)
      
      Text(forecast.temperature)
    }
  }
}
 HStack {
  ForEach(weather.hourlyForecast, id: \.hour) { forecast in
    HourlyForecast(forecast: forecast)
  }
}
 HStack {
  ForEach(weather.hourlyForecast, id: \.hour) { forecast in
    🟢Spacer()
    HourlyForecast(forecast: forecast)
    🟢Spacer()
  }
}