GifListCollectionViewFlowLayout.swift 607 B

12345678910111213141516171819202122
  1. //
  2. // GifListCollectionViewFlowLayout.swift
  3. import UIKit
  4. class GifListCollectionViewFlowLayout: UICollectionViewFlowLayout {
  5. override func prepare() {
  6. super.prepare()
  7. guard let collectionView = collectionView else { return }
  8. let availableWidth = collectionView.bounds.inset(by: collectionView.layoutMargins).width
  9. let cellWidth = (availableWidth / 2).rounded(.down)
  10. self.itemSize = CGSize(width: cellWidth, height: cellWidth)
  11. self.sectionInset = UIEdgeInsets(top: 0.0, left: 0.0, bottom: 0.0, right: 0.0)
  12. }
  13. }