I have a UICollectionView with a cell only contain of one label. I've implemented it working fine, but some string values set to label inside cell cut out. Check below image.
Select cell should display as "Day Before Yesterday". If there's a way to adjust cell width base on data length I can fix this. is it possible ?
PS: some similar questions suggested below method. so I've tried it but no luck.
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
if(collectionView == dateRangeCollectionView){
return (dateRanges[indexPath.item] as NSString).size(attributes: nil)
}else{
return (OrderStatus[indexPath.item] as NSString).size(attributes: nil)
}
}
I don't think this method even exist in swift 4. when I start to type "sizeForItemAt" Xcode didn't suggest this method.