How to make Supplementary View float in UICollectionView as Section Headers do in UITableView plain style

后端 未结 13 726
逝去的感伤
逝去的感伤 2020-11-27 09:35

I\'m struggling to achieve a \"floating section header\" effect with UICollectionView. Something that\'s been easy enough in UITableView (default b

13条回答
  •  被撕碎了的回忆
    2020-11-27 10:32

    Swift 5.0

    Put the following in your viewDidLoad:

    if let layout = collectionView?.collectionViewLayout as? UICollectionViewFlowLayout {
        layout.sectionHeadersPinToVisibleBounds = true
    }
    

提交回复
热议问题