Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
fileprivate let collectionView:UICollectionView = {
let layout = UICollectionViewFlowLayout()
layout.scrollDirection = .horizontal
let cv = UICollectionView(frame: .zero, collectionViewLayout: layout)
cv.translatesAutoresizingMaskIntoConstraints = false
cv.register(CustomCell.self, forCellWithReuseIdentifier: "cell")
return cv
func setupCollectionView(){
collectionView.delegate = self
collectionView.dataSource = self
collectionView.topAnchor.constraint(equalTo: view.topAnchor, constant: 40).isActive = true
collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 8).isActive = true
collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -8).isActive = true
collectionView.heightAnchor.constraint(equalToConstant: 90).isActive = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment