I would like the UICollectionView (The red one) to shrink to the height of the content size in this case UICollectionViewCells(the yellow ones) because there is a lot of emp
I ended up, by subclassing the UICollectionView and overriding some methods as follows.
self.collectionViewLayout.collectionViewContentSize for intrinsicContentSize makes sure, to always have the correct sizereloadData)Code:
override func reloadData() {
super.reloadData()
self.invalidateIntrinsicContentSize()
}
override var intrinsicContentSize: CGSize {
return self.collectionViewLayout.collectionViewContentSize
}
But be aware, that you lose "cell re-using", if you display large sets of data, eventhough they don't fit on the screen.