Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UICollectionView horizontal scroll with vertical header

I am creating a UICollectionView which scrolls horizontally but with a vertical section header.

My problem is that for horizontal scrolling, the section header defaults to the left side of the collection view and I cannot adjust it to the top of the UICollectionView.

I have checked out various solutions which includes DateFlowLayout which unfortunately does not work anymore.

enter image description here

like image 220
Wraithseeker Avatar asked Sep 06 '25 07:09

Wraithseeker


1 Answers

You have to implement your own collection view layout to do so.

The easiest would be to subclass UICollectionViewFlowLayout and override

- (UICollectionViewLayoutAttributes *)layoutAttributesForSupplementaryViewOfKind:(NSString *)elementKind atIndexPath:(NSIndexPath *)indexPath;

to give the frame you wish for the header

like image 63
Jaeger Avatar answered Sep 07 '25 21:09

Jaeger