I am creating a UICollectionView which scrolls horizontally but with a vertical section header.
我正在创建一个UICollectionView,它水平滚动,但有一个垂直剖面标题。
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.
我的问题是,对于水平滚动,节标题默认为集合视图的左侧,我无法将其调整到UICollectionView的顶部。
I have checked out various solutions which includes DateFlowLayout which unfortunately does not work anymore.
我已经检查了各种解决方案,包括DateFlowLayout,遗憾的是它不再起作用了。
1 个解决方案
#1
4
You have to implement your own collection view layout to do so.
您必须实现自己的集合视图布局才能执行此操作。
The easiest would be to subclass UICollectionViewFlowLayout and override
最简单的是子类UICollectionViewFlowLayout和覆盖
- (UICollectionViewLayoutAttributes *)layoutAttributesForSupplementaryViewOfKind:(NSString *)elementKind atIndexPath:(NSIndexPath *)indexPath;
- (UICollectionViewLayoutAttributes *)layoutAttributesForSupplementaryViewOfKind:(NSString *)elementKind atIndexPath:(NSIndexPath *)indexPath;
to give the frame you wish for the header
给出标题所需的帧
#1
4
You have to implement your own collection view layout to do so.
您必须实现自己的集合视图布局才能执行此操作。
The easiest would be to subclass UICollectionViewFlowLayout and override
最简单的是子类UICollectionViewFlowLayout和覆盖
- (UICollectionViewLayoutAttributes *)layoutAttributesForSupplementaryViewOfKind:(NSString *)elementKind atIndexPath:(NSIndexPath *)indexPath;
- (UICollectionViewLayoutAttributes *)layoutAttributesForSupplementaryViewOfKind:(NSString *)elementKind atIndexPath:(NSIndexPath *)indexPath;
to give the frame you wish for the header
给出标题所需的帧