GifListCollectionViewFlowLayout.swift 684 B

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