Reputation: 177
I'm kind of stuck with a problem here. So, I've got a UICollectionView with a textView inside. The problem is, that I need to change the collectionViewCell's height and therefor it's y-position in the collectionView if I'm adding a line of text to the textView. Unfortunately, everything I tried doesn't work. Here's what it looks like:
(I'm not allowed to post full size screenshots)
Green = collectionViewBackground, black = cell's background
Does somebody know how to make the green disappear?
Upvotes: 0
Views: 39
Reputation: 10012
Make your viewcontroller implements UICollectionViewDelegateFlowLayout and override the sizeForItemAt function
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let data: String = list[indexPath.row] //Your data for specific index
let size = data.size(attributes: nil)
return size
}
This should help you resolve your problem and don't forget to set collectionview.delegate = self //Your view Controller
Upvotes: 1