How do I properly resize a UICollectionView so that it fully displays its contents? I have tried many things, including setting its frame, calling reloadData an
Here's a way to bind the CollectionView's height via it's intrinsic size. I used it to properly size a CollectionView inside a TableView Cell (with dynamic cells height). and it works perfectly.
First, add this to your UICollectionView subclass:
override var intrinsicContentSize: CGSize {
get {
return self.contentSize
}
}
Then call layoutIfNeeded() after you reload data:
reloadData()
layoutIfNeeded()