Lazy grids
If you need a way to display larger grids containing a vast number of elements, you need lazy grids. Lazy grids come in two varieties: LazyHGrid
(horizontal) or LazyVGrid
(vertical), depending on which direction you want to scroll. In order for the grid to scroll, you will need to place the grid inside ScrollView
:
import SwiftUI struct ContentView: View { var body: some View { ScrollView { LazyVGrid(columns: [GridItem(.flexible()),GridItem(.flexible()),GridItem(.flexible()),GridItem(.flexible()),]) { ForEach(1...300, id: \.self) { I in &...