32.1 SwiftUI Grids
SwiftUI grids provide a way to display information in a multicolumn layout oriented either horizontally or vertically. When embedded in a ScrollView instance, the user will be able to scroll through the grid if it extends beyond the visible screen area of the device in which the app is running.
As the names suggests, the LazyVGrid and LazyHGrid views only create items to be displayed within the grid when they are about to become visible to the user and then discards those items from memory as they scroll out of view (a concept covered previously in the chapter entitled “SwiftUI Stacks and Frames”). This allows scrollable grids of potentially infinite numbers of items to be constructed without adversely impacting app performance.
The syntax for declaring a vertical grid is as follows:
LazyVGrid(columns: [GridItem], alignment: <horizontal alignment>,
...