Dynamic cell width of UICollectionView depending on label width

前端 未结 7 1366
别跟我提以往
别跟我提以往 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:12

    //add in view didload

    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
        [layout setScrollDirection:UICollectionViewScrollDirectionHorizontal];
        layout.estimatedItemSize = CGSizeMake(self.breadScrumbCollectionView.frame.size.width, 30); 
    self.breadScrumbCollectionView.collectionViewLayout = layout;
    

提交回复
热议问题