Skip to content

Instantly share code, notes, and snippets.

@wdchris
Last active May 18, 2020 17:27
Show Gist options
  • Save wdchris/ba89c28cc459e41051c559409de10e2e to your computer and use it in GitHub Desktop.
Save wdchris/ba89c28cc459e41051c559409de10e2e to your computer and use it in GitHub Desktop.
override func viewDidLoad() {
super.viewDidLoad()
contentView.addSubview(collectionView)
collectionView.topAnchor.constraint(equalTo: self.contentView.topAnchor, constant: 0).isActive = true
collectionView.bottomAnchor.constraint(equalTo: self.contentView.bottomAnchor, constant: 0).isActive = true
collectionView.leadingAnchor.constraint(equalTo: self.contentView.leadingAnchor, constant: 0).isActive = true
collectionView.trailingAnchor.constraint(equalTo: self.contentView.trailingAnchor, constant: 0).isActive = true
}
lazy var collectionView: UICollectionView = {
let layout = collectionViewFlowLayout
let collectionView = UICollectionView(frame: self.contentView.frame, collectionViewLayout: layout)
collectionView.backgroundColor = UIColor.white
collectionView.translatesAutoresizingMaskIntoConstraints = false
return collectionView
}()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment