Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save JeremyXue77/ed23121d6659156b8859421619795afa to your computer and use it in GitHub Desktop.

Select an option

Save JeremyXue77/ed23121d6659156b8859421619795afa to your computer and use it in GitHub Desktop.
extension ViewController: UICollectionViewDelegateFlowLayout {
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let width = collectionView.bounds.width / CGFloat(row * 2 - 1)
return CGSize(width: width, height: width)
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
let width = collectionView.bounds.width / CGFloat(row * 2 - 1)
return width
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
let width = collectionView.bounds.width / CGFloat(row * 2 - 1)
return width
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment