We commonly use Collection view where its cell size calculated run time. The flow layout delegate is responsible to return individual cell sizes. BUT in most of the cases, delegate method `collectionView: layout sizeForItem:` expects cell size too early. Before generating actual cell size.  extension  YourViewController : UICollectionViewDelegateFlowLayout  {     func  collectionView ( _  collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath)  -> CGSize  {         return  CGSize (width: externalWidth, height: externalHeight)     } }  For instance, if a cell size depends on external view and its frame is not yet ready - results with wrong (or outdated) cell size. Typically happens for the first time view controller laid out all views.   You can find similar queries in StackOverflow community :    Collection view sizeForItemNotWorking  UICollectionViewCell content wrong size on first load  How to refresh UICollec...