Answers for "array of views swiftui"

5

swiftui foreach

ForEach(1...5) { row in
    Text("Row \(row)")
}
Posted by: Guest on March-04-2020
1

foreach swiftui object

struct ContentView: View {
    let colors: [Color] = [.red, .green, .blue]

    var body: some View {
        VStack {
            ForEach(colors, id: \.self) { color in
                Text(color.description.capitalized)
                    .padding()
                    .background(color)
            }
        }
    }
}
Posted by: Guest on January-07-2020

Code answers related to "Swift"

Browse Popular Code Answers by Language