Component - Grid layout (LazyVGrid, LazyHGrid)
This UI component shows how to arrange items in a grid using SwiftUI's LazyVGrid and LazyHGrid. It helps display many items efficiently in rows and columns that scroll vertically or horizontally.
This UI component shows how to arrange items in a grid using SwiftUI's LazyVGrid and LazyHGrid. It helps display many items efficiently in rows and columns that scroll vertically or horizontally.
VStack ├── Text (Title) ├── ScrollView (Vertical) │ └── LazyVGrid │ ├── ForEach (Grid Items) │ │ └── Rectangle (Grid Cell) ├── Divider ├── ScrollView (Horizontal) │ └── LazyHGrid │ ├── ForEach (Grid Items) │ │ └── Rectangle (Grid Cell)
LazyVGrid do in SwiftUI?LazyVGrid?LazyHGrid(rows: [GridItem(.fixed(50))]) {
ForEach(0..<3) { i in
Text("Item \(i)")
}
}LazyVGrid(rows: [GridItem(.flexible())]) {
Text("Hello")
Text("World")
}LazyVGrid?Pass the test and this pattern moves unknown