ForEach
Iterate over collections to generate views dynamically using ForEach.
ForEach
Render a list of items using ForEach.
Example
Demo.swift
ContentView.swift
App.swift
import SwiftUI
struct ForEachDemo: View {
let nums = [1,2,3]
var body: some View {
VStack {
ForEach(nums, id: \.self) { n in
Text("Item \(n)")
}
}
}
}
Leave a Reply