I am building a collection view, every cell has a fixed width but a varying height. There should be a border of 1 px within each cell. I have tried to find a way to make them vertically align but end up with white space in between them. Also some times the cells end up on top of each other.
What would be the best wat to solve this problem. I have considered subclassing UICollectionViewFlowLayout
I am currently setting the size like this:
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout,sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
return CGSize(width: CGFloat(defaultCellSize), height: CGFloat(defaultCellSize * ratio))
}
Try using this library https://github.com/chiahsien/CHTCollectionViewWaterfallLayout It has handled what is required.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With