0

What's the issue?

So, I have a UICollectionView inside a UITableView which is all working alright. I'm updating the size of the collectionViewCell in the sizeForItemAt method.

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {

    if collectionView.tag == 0 {

        return CGSize(width: self.box(text: headerTags[indexPath.row], fontSize: 16, fontName: "Arial").0 + 50, height: 40)
    }
    else {

        return CGSize(width: self.box(text: footerTags[indexPath.row], fontSize: 16, fontName: "Arial").0 + 50, height: 40)
    }
}

Now, the cell's background view changes it's size but the content view isn't and so I can't achieve the desired results.

Here's what's happening:

enter image description here

The black coloured view is the content view and the light gray view adjoining it is the cell's background.

Edit:

I did a bit more research and the problem lies in the sizeForItem method not updating the contentView of the cell.

Ameya Vichare
  • 1,119
  • 1
  • 10
  • 22

0 Answers0