Can ios uicollectionview set different heights for different section?

for example, in section=0, when the height in section is 50, the height in section is 100. How to set this?

Mar.14,2021

you can search the waterfall flow and modify the system method in UICollectionViewLayout

  • (instancetype) init
  • (void) prepareLayout
  • (NSArray < UICollectionViewLayoutAttributes > ) layoutAttributesForElementsInRect: (CGRect) rect
  • (CGSize) collectionViewContentSize

The following methods of

UICollectionViewDelegateFlowLayout may be what you need.

  • (CGSize) collectionView: (UICollectionView ) collectionView layout: (UICollectionViewLayout ) collectionViewLayout referenceSizeForHeaderInSection: (NSInteger) section;
Menu