Skip to content

Instantly share code, notes, and snippets.

@laevandus
Created August 1, 2021 05:36
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 laevandus/e42b649a20e2bb9a84e629dc0ff9b43b to your computer and use it in GitHub Desktop.
Save laevandus/e42b649a20e2bb9a84e629dc0ff9b43b to your computer and use it in GitHub Desktop.
private var collectionViewHeightConstraint: NSLayoutConstraint!
override func viewDidLoad() {
super.viewDidLoad()
collectionView.register(TextCollectionViewCell.self, forCellWithReuseIdentifier: Self.reuseIdentifier)
collectionView.backgroundColor = UIColor(white: 0.9, alpha: 1)
collectionView.isScrollEnabled = false
collectionViewHeightConstraint = collectionView.heightAnchor.constraint(equalToConstant: 50)
collectionViewHeightConstraint.isActive = true
}
override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
collectionViewHeightConstraint.constant = collectionViewLayout.collectionViewContentSize.height
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment