我有xib,我注册了它:
[self.collectionView registerNib:[UINib nibWithNibName:@"MyCollectionView" bundle:nil] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"MyCollectionView"];
我希望将它粘贴到导航栏 - 每次都必须在导航栏下(例如,当我滚动页面时)。如何将其固定(导航)到导航栏?
答案 0 :(得分:1)
在您的流布局文件初始化中,您可以使用:
self.sectionHeadersPinToVisibleBounds = true
如果您在viewDidLoad
使用
let layout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout // casting is required as its feature of UICollectionViewFlowLayout
layout?.sectionHeadersPinToVisibleBounds = true
目标C版
UICollectionViewFlowLayout *layout = (UICollectionViewFlowLayout*) collection.collectionViewLayout;
layout.sectionHeadersPinToVisibleBounds = YES;