Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save harrysummers/6bc5d52897feca8afd24271c5346051d to your computer and use it in GitHub Desktop.
Save harrysummers/6bc5d52897feca8afd24271c5346051d to your computer and use it in GitHub Desktop.
UICollectionView programmatically
lazy var collectionView: UICollectionView = {
let layout = UICollectionViewFlowLayout()
layout.itemSize = CGSize(width: 140, height: 250)
layout.scrollDirection = .horizontal
let collection = UICollectionView(frame: self.view.frame, collectionViewLayout: layout)
collection.translatesAutoresizingMaskIntoConstraints = false
collection.register(GifCollectionViewCell.self, forCellWithReuseIdentifier: cellId)
collection.backgroundColor = UIColor.CustomColors.spotifyDark
collection.bounces = true
collection.alwaysBounceHorizontal = true
collection.alwaysBounceVertical = false
collection.delegate = self
collection.dataSource = self
return collection
}()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment