UICollectionView in SwiftUI!!!

Dima Virych
Nov 5 · 2 min read

Hey all. If you started to learn SwiftUI you may see that it has no CollectionView. Can we create it? Why NOT!?

Let’s start!

We need to create viewModel for our CollectionView. Let’s do it:

In this step, we created a protocol for our viewModel
var layout must provide a base layout for our collectionView

Let’s create viewModel class!

Now we have base UICollectionView Datasource class =)
And one more thing!

Creating CollectionView for SwiftUI!!!

YEAH, BABY!!!! We have our loving UICollectionView on the SwiftUI!!!

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade