0
0
iOS Swiftmobile~5 mins

Grid layout (LazyVGrid, LazyHGrid) in iOS Swift - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is LazyVGrid in SwiftUI?
LazyVGrid is a SwiftUI view that arranges child views in a vertical grid. It loads views only when needed, improving performance for large data sets.
Click to reveal answer
beginner
How does LazyHGrid differ from LazyVGrid?
LazyHGrid arranges child views in a horizontal grid, loading views lazily as they appear on screen, unlike LazyVGrid which arranges vertically.
Click to reveal answer
intermediate
What is the role of GridItem in LazyVGrid or LazyHGrid?
GridItem defines the size and spacing of each column (in LazyVGrid) or row (in LazyHGrid). You can specify fixed, flexible, or adaptive sizes.
Click to reveal answer
intermediate
Why use lazy grids instead of regular grids in SwiftUI?
Lazy grids load views only when they appear on screen, saving memory and improving performance, especially with many items.
Click to reveal answer
beginner
How do you make a grid with 3 equal columns using LazyVGrid?
Create an array of three GridItems with .flexible() size and pass it to LazyVGrid's columns parameter.
Click to reveal answer
Which SwiftUI view arranges items in a vertical grid and loads views lazily?
AVStack
BLazyVGrid
CLazyHGrid
DHStack
What does a GridItem with .fixed(100) size mean?
AThe grid item is exactly 100 points wide or tall
BThe grid item can grow or shrink flexibly
CThe grid item adapts to available space
DThe grid item is hidden
Which grid type arranges items horizontally in SwiftUI?
ALazyHGrid
BZStack
CGridStack
DLazyVGrid
Why is lazy loading important in grids?
AIt changes colors automatically
BIt loads all views at once
CIt disables scrolling
DIt improves performance by loading views only when needed
How do you specify spacing between columns in LazyVGrid?
AUsing padding on each item
BUsing frame modifiers
CUsing the spacing parameter in LazyVGrid initializer
DSpacing is not customizable
Explain how to create a simple 2-column vertical grid using LazyVGrid in SwiftUI.
Think about how you define columns and place views inside LazyVGrid.
You got /3 concepts.
    Describe the benefits of using LazyHGrid over a regular horizontal stack for many items.
    Consider what happens when you have many items off screen.
    You got /3 concepts.