How to make a Waterfall UICollectionView using Swift
- October 10, 2019
- John Codeos
Today, I am going to show you how to add a waterfall layout in your UICollectionView, like Pinterest’s, quick and easy using CHTCollectionViewWaterfallLayout.
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:
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!