goldball
10/17/2019 - 7:10 PM

Collection View Cell Size

public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
        
        let numberOfColumns : CGFloat = 2
        let width = collectionView.frame.size.width
        let xInsects : CGFloat = 10
        let cellSpacing : CGFloat = 5
    

        return CGSize(width: (width / numberOfColumns) - (xInsects + cellSpacing),  height: (width / numberOfColumns) - (xInsects + cellSpacing))
}