Skip to content

Instantly share code, notes, and snippets.

@anupamchugh
Created November 21, 2019 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anupamchugh/b0e4a69b5e037aa077bf9b82c7e3917f to your computer and use it in GitHub Desktop.
Save anupamchugh/b0e4a69b5e037aa077bf9b82c7e3917f to your computer and use it in GitHub Desktop.
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(){
view.addSubview(collectionView)
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