UICollectionView with a sticky header

前端 未结 6 465
名媛妹妹
名媛妹妹 2020-12-07 10:13

I found a blog on how to make sticky headers and it works great. Only thing is I don\'t think it takes into account the sectionInserts.

This is how its intended to l

6条回答
  •  孤城傲影
    2020-12-07 10:45

    Simplest solution for iOS 9 + as it doesn't need of writing subclass of UICollectionViewFlowLayout.

    In viewDidLoad of viewController with collectionView use following code:

    let layout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout // casting is required because UICollectionViewLayout doesn't offer header pin. Its feature of UICollectionViewFlowLayout
    layout?.sectionHeadersPinToVisibleBounds = true
    

提交回复
热议问题