How to make a Waterfall UICollectionView using Swift

How to make a Waterfall UICollectionView using Swift

Today, I am going to show you how to add a waterfall layout in your UICollectionView, like Pinterest’s, quick and easy using CHTCollectionViewWaterfallLayout.

Pinterest’s CollectionView with Waterfall layout

First, we have to add CHTCollectionViewWaterfallLayout into our project.

Go to the Github page and download the repo:

..unzip it, copy the file CHTCollectionViewWaterfallLayout.swift and paste it into the project:

Add to your ViewController class who has the CollectionView the CHTCollectionViewDelegateWaterfallLayout delegate, set width and height for each item and the number of columns you want, like that:

..and lastly, set the CHTCollectionViewWaterfallLayout as layout into our CollectionView:

That’s it!

You can find the final project here

If you have any questions feel free to DM me on Twitter @johncodeos or leave a comment below!

Leave a Reply

Notify of

Follow me