UICollectionView estimatedItemSize - last cell is not aligned UICollectionView estimatedItemSize - last cell is not aligned ios ios

UICollectionView estimatedItemSize - last cell is not aligned


I face a similar issue and the problem was solved by giving a proper minimum inter item spacing, using the delegate methods - minimumInteritemSpacingForSectionAt- of UICollectionViewDelegateFlowLayout.


You are setting estimatedItemSize in the init of view itself.

You need to set it in some controller.

Also,

If all of your cells are the same height, use the itemSize property, instead of this property, to specify the cell size instead.

Documentation: estimatedItemSize


there is a simple method to resolve this. You can add number of prototype cells to check the cell at required position. Once you find the issue at last cell . Check the cell insets in Inspector window.