Skip to content

Instantly share code, notes, and snippets.

@iAmrSalman
Last active January 16, 2018 08:09
Show Gist options
  • Save iAmrSalman/8e73f1c3779aeef12d4c35fcc9705fa5 to your computer and use it in GitHub Desktop.
Save iAmrSalman/8e73f1c3779aeef12d4c35fcc9705fa5 to your computer and use it in GitHub Desktop.
[setup collectionView] #uicollectionview #swift3
private func setupCollectionView() {
collectionView.delegate = self
collectionView.dataSource = self
collectionView.register(UINib.init(nibName: "NIB_NAME", bundle: nil), forCellWithReuseIdentifier: "cell")
setupCellSizing()
}
private func setupCellSizing() {
let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout()
layout.sectionInset = UIEdgeInsets(top: 10, left: 0, bottom: 10, right: 0)
let height = UIScreen.main.bounds.height * 0.23
layout.itemSize = CGSize(width: height, height: height)
layout.scrollDirection = .horizontal
layout.minimumLineSpacing = 1.0
layout.minimumInteritemSpacing = 1.0
collectionView.setCollectionViewLayout(layout, animated: true)
collectionView.reloadData()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment