COLLECTIONVIEW - GRIDVIEW IN SWIFTUI | iOS | LAZYVGRID

Опубликовано: 02 Май 2026
на канале: BBUniversal Team
62
2

#gridinswiftui,
#gridlayoutinswiftui,
#howtousegridviewinswiftui,
#gridviewswift,
#cardviewinswiftui,

COLLECTIONVIEW - GRIDVIEW IN SWIFTUI
Github: https://github.com/GithubAshishHere/C...
✓ Create New SWIFTUI Project.
✓ select SwiftUI In both place Interface and Life Cycle
✓ Let’s remove hello word.

✓ We are going to use LazyHGrid and LazyVGrid

✓ There are three type of Layout:
⁃ .flexible()
⁃ .fixed()
⁃ .adaptive()

✓ We are going to use .flexible()

✓ Open ContentView.swift

✓ Add below variable inside Struct ContentView
⁃ private var gridItemLayout = [GridItem(.flexible())]
⁃ Above code specify layout
⁃ So we are using flexible

✓ Now Add LazyVGrid (V stands for Vertical Grid)
✓ In columns: parameters

✓ Add gridItemLayout layout inside LazyVGrid and spacing:20

✓ Now Add Images to the project by drag and drop to Assets.Xcassets
✓ Add 5 images.

✓ Create Array of the with name of images file name as shown Below
⁃ private var profiles = ["Profile1","Profile2","Profile3","Profile4","Profile5"]
✓ Now add images inside LazyVGrid with ForEach

✓ Now let’s run app.
✓ Now we get the images. But it is not scrollable. To make it scrollable we going to add ScrollView
Now Image is scrolling :)

In Next Video I will show you horizontal scroll of CollectionView in SwiftUI.

Let's grow together.
If you have any suggestions. please comment below.
Learn iOS Development in a short time from the below links.
Learn iOS Development Free.

You can also get in touch with on Facebook page link below:
Facebook Page:   / iostechcodex  
If you have any query just comment below or message on the Facebook page.


Thank you.