Swift 3: How to center horizontally the last row of cells in a UICollectionView with only one section?
I'm using a UICollectionView with only one section. Here's some visualization: [ x x x ] [ x x x ] [ x x ] If the last row in the UICollectionView does not have all 3 cells filled, I'd like to center those cells like so: [ x x x ] [ x x x ] [ x x ] I've tried to implement solutions from the following places: How to center horizontally UICollectionView Cells? How to center align the cells of a UICollectionView? However, the solutions shifts all the cells, and I'd like to only shift the LAST row if that last row doesn't contain X number of cells since I only have one section. I know how to set