change the height of a UICollectionReuseableView (collection section header) dynamically

Your delegate should implement the following function, assuming you’re using a flow layout:

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section;

You can return a different size for each header. In horizontally scrolling collection views, only the width is used. In vertically scrolling ones, only the height is used. The unused value is ignored — your view will always be stretched to fill the full height/width of horizontal/vertical collection views, respectively.

There is a corresponding method for footers, too.

Leave a Comment

techhipbettruvabetnorabahisbahis forumu