Last active
January 16, 2018 08:09
-
-
Save iAmrSalman/8e73f1c3779aeef12d4c35fcc9705fa5 to your computer and use it in GitHub Desktop.
[setup collectionView] #uicollectionview #swift3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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