Dynamic cell width of UICollectionView depending on label width

前端 未结 7 1336
别跟我提以往
别跟我提以往 2020-11-28 02:44

I have a UICollectionView, that loads cells from reusable cell, which contains label. An array provides content for that label. I can resize label width depending on content

相关标签:
7条回答
  • 2020-11-28 03:19

    Checkout below code you might be giving very short CGSize.

    - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
    
        NSString *testString = @"SOME TEXT";
        return [testString sizeWithAttributes:NULL];
    }
    
    0 讨论(0)
提交回复
热议问题