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.

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)) }
source share