'How to make height display cell respond to different content sizes

curent state

collectionViewCell has 3 labels. Now the dimensions are set in this method:

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize
    {
        return CGSize(width: 382, height: 112)
    }

And I want to calculate the sizes based on the sizes of these Label. How to do it?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source