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

后端 未结 13 723
逝去的感伤
逝去的感伤 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:28

    @iPrabu had an excellent answer with sectionHeadersPinToVisibleBounds. I’ll just add that you can set this property in Interface Builder as well:

    1. Select the flow layout object in the document navigator. (If collapsed, expand it first using the toolbar button in the lower-left corner of the editor.)

    1. Open the Identity inspector and add a user-defined runtime attribute with key path sectionHeadersPinToVisibleBounds, type Boolean, and the checkbox checked.

    The default header view has a transparent background. You might want to make it (partially) opaque or add a blur effect view.

提交回复
热议问题