Q:

How to auto resize contents in CollectionViewCell after the cell's size changed?

In Xcode, I created a UICollectionView and dragged some labels to the UICollectionViewCell. The issue was that when changing devices, the cell won't adjust its size to the screen size. So I implemented the following code:
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {

let layout = collectionView.collectionViewLayout as! UICollectionViewFlowLayout

layout.sectionInset = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)

return CGSize(width: self.collectionView.frame.width * 0.9, height:self.collectionView.frame.height *0.8)   

}

After this, I noticed that the cell's size did change. However, the  width and height of the labels inside the cell remained the same. 
I'm not sure how to resolve this problem. 
Thank you in advance for your help!!

A:

set Constraint of your labels,
like,
for Constraint pic.
your label pic.
or you can also use UI property autoresizingMask 
like,
yourLbl.autoresizingMask = [.flexibleWidth, .flexibleHeight]

