Vertically aligned Collection view cells with different heights

I create a collection view, each cell has a fixed width but a different height. Each cell should have a border of 1 px. I tried to find a way to make them vertically aligned, but ended up with a space between them. Also, several times the cells are on top of each other.

Collection View Example

What will be the best wat to solve this problem. I examined subclasses of UICollectionViewFlowLayout

I am currently setting the size as follows:

 func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout,sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize { return CGSize(width: CGFloat(defaultCellSize), height: CGFloat(defaultCellSize * ratio)) } 
+5
source share
1 answer

Try using this library https://github.com/chiahsien/CHTCollectionViewWaterfallLayout It handles what is required.

+1
source

All Articles