How to adjust height of UICollectionView to be the height of the content size of the UICollectionView?

后端 未结 14 1121
死守一世寂寞
死守一世寂寞 2020-11-28 03:51

I would like the UICollectionView (The red one) to shrink to the height of the content size in this case UICollectionViewCells(the yellow ones) because there is a lot of emp

14条回答
  •  暖寄归人
    2020-11-28 04:32

    work for me

        let heightRes = resCollectionView.collectionViewLayout.collectionViewContentSize.height
        foodHeightConstrant.constant = height.advanced(by: 1 )
    
        foodCollectionView.setNeedsLayout()
        foodCollectionView.layoutIfNeeded()
    

提交回复
热议问题