I have a UICollectionView
with a header of type UICollectionReusableView
.
In it, I have a label whose length varies by user input.
Swift 3
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize{
return CGSize(width: self.myCollectionView.bounds.width, height: self.mylabel.bounds.height)
}
https://developer.apple.com/reference/uikit/uicollectionviewdelegateflowlayout/1617702-collectionview