// // GifListCollectionViewFlowLayout.swift import UIKit class GifListCollectionViewFlowLayout: UICollectionViewFlowLayout { override func prepare() { super.prepare() guard let collectionView = collectionView else { return } let availableWidth = collectionView.bounds.inset(by: collectionView.layoutMargins).width let cellWidth = (availableWidth / 2).rounded(.down) self.itemSize = CGSize(width: cellWidth, height: cellWidth) self.sectionInset = UIEdgeInsets(top: 0.0, left: 0.0, bottom: 0.0, right: 0.0) } }