Here is my code, and I'm wondering how can I allow all 4 arrays to be used in the ForEach statement as right now I can only use 2.
struct ContentView: View {
var array1 = ["1", "2", "3"]
var array2 = ["a", "b", "c"]
var array3 = ["!", "@", "#"]
var array4 = ["+", "-", "~"]
var body: some View {
VStack {
HStack {
Text("Upcoming Flights")
.font(.title2)
.fontWeight(.bold)
Spacer()
}
ScrollView(.horizontal) {
HStack {
ForEach(Array(zip(array1, array2)), id: \.0) { item in
VStack {
Group {
Text("Flight")
Text(item.0)
.padding(.bottom)
.font(.caption)
.foregroundColor(.gray)
Text("Instructor")
Text(item.1)
.font(.caption)
.foregroundColor(.gray)
}
}
.frame(width: 110, height: 140)
.overlay {
RoundedRectangle(cornerRadius: 10)
.stroke(.gray.opacity(0.3), lineWidth: 1)
}
Spacer()
}
}
.frame(height: 200)
}
.frame(height: 200)
.offset(y: -25)
}
.offset(y: -10)
.padding([.leading, .trailing, .bottom])
}
}
Thanks in advance. @jnpdx I hope this helps, and I made sure it was reproducible. I don't want the arrays combined, but set as Text, like the first two arrays all in the same Stack in the view.