📜  foreach swiftui 对象 - Swift 代码示例

📅  最后修改于: 2022-03-11 15:01:01.349000             🧑  作者: Mango

代码示例1
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)
            }
        }
    }
}