I am trying to make custom cell height
. But the next cell is starting from the maxY
of previous cell. I want to fill the gap there. How to achieve that ?
This is what I am getting now :
Here the 3rd cell is in the vertically centered
to 4th cell, but it should be match the minY
of 4th cell.
Here is how I am calculating size :
extension SomeController: UICollectionViewDelegateFlowLayout {
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let spacing: CGFloat = 10
let smallestWidth = collectionView.bounds.width/3 - spacing
if indexPath.item % 9 == 0 && indexPath.item != 0 {
return CGSize(width: collectionView.bounds.width, height: smallestWidth * 2)
} else if indexPath.item % 4 == 0 && indexPath.item != 0 && indexPath.item % 8 != 0 {
return CGSize(width: smallestWidth * 2, height: smallestWidth * 2)
} else {
return CGSize(width: smallestWidth, height: smallestWidth )
}
}
}