I am just trying to dynamically size cells. I followed a few SO Questions and cannot seem to produce the same results. Example one Example two
My code right now is:
extension ItemViewController: UICollectionViewDelegateFlowLayout {
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let text = allTags[indexPath.item]
tagName.text = text //label from my custom cell (xCode not recognizing)
return CGRect(width: tagName.intrinsicContentSize.width + 60, height: 40)
}
}
In the second line, tagName is not identified by Xcode. It is part of my custom cell class. The first SO question I linked somehow was able to identify their cell properties within sizeForItemAt. How would I do that to dynamically size my cells? I do have estimated size to non-nil:
if let collectionViewLayout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout {
collectionViewLayout.estimatedItemSize = UICollectionViewFlowLayout.automaticSize
}
My desired result in similar to the photos. Let me know if you need more info. Thank you.

