I have a label that is set to resize to its content. I want the UICollectionViewCell to do the same. I cannot find anyway to implement that.
A picture describing my current arrangement can be found below:
I have a label that is set to resize to its content. I want the UICollectionViewCell to do the same. I cannot find anyway to implement that.
A picture describing my current arrangement can be found below:
I think you'll want to implement the UICollectionViewDelegateFlowLayout method collectionView:layout:sizeForItemAtIndexPath: to adjust the size of each collection item based on the contents.
Here's a tutorial on Collection Views that covers this specific topic.
Use "Autolayout" in cell's Interface Builder document. After setting constraints, your cell frame is going to dynamically change.
configure collection:
YOU_Collection.layout.estimatedItemSize = CGSize(width: 1, height: 1)
and in cell add label constraints (top and bottom)