BikeView mit ForEach

This commit is contained in:
Ingo Rohlf 2025-10-21 09:39:09 +02:00
parent 8eef26c4a4
commit 37ae8487be
3 changed files with 10 additions and 3 deletions

View file

@ -5,7 +5,7 @@ import SwiftUI
struct TheSwiftWeek: App {
var body: some Scene {
WindowGroup {
Text("Moin")
BikeView()
}
}
}

View file

@ -2,12 +2,19 @@
import SwiftUI
struct BikeView: View {
var bike = Bike(name: "Fahrrad", color: "lila")
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
Text(bike.description)
Text(bike.name)
ForEach(1...5, id: \.self) { number in
Text(bike.color + " " + String(number))
}
}
}
#Preview {
#Preview {
BikeView()
}