Reputation: 91
I want to know how to dynamically create multiple SwiftUI shapes (e.g. Rectangles).
How does one go from something like this:
struct ContentView: View {
var body: some View {
Rectangle()
.fill(Color.blue)
.frame(width: 100, height: 100)
}
}
To something like this:
struct ContentView: View {
var body: some View {
VStack {
for index 1...10 {
Rectangle()
.fill(Color.black)
.frame(width:100, height: 100)
}
}
}
}
Upvotes: 0
Views: 288