UICollectionView Set number of columns
With Swift 5 and iOS 12.3, you can use one the 4 following implementations in order to set the number of items per row in your UICollectionView while managing insets and size changes (including rotation). #1. Subclassing UICollectionViewFlowLayout and using UICollectionViewFlowLayout‘s itemSize property ColumnFlowLayout.swift: import UIKit class ColumnFlowLayout: UICollectionViewFlowLayout { let cellsPerRow: Int init(cellsPerRow: Int, … Read more