Reputation: 759
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))
}
Upvotes: 5
Views: 1015
Reputation: 858
Try using this library https://github.com/chiahsien/CHTCollectionViewWaterfallLayout It has handled what is required.
Upvotes: 1