Tag: 补充

如何使补充视图在UICollectionView中浮动为UITableView普通样式的Section Headers

我努力实现与UICollectionView “浮动部分标题”效果。 在UITableView ( UITableView默认行为)中已经足够容易了,在UICollectionView似乎是不可能的。 我是否错过了明显的? 苹果公司没有提供如何实现这一目标的文件。 看来,人们必须UICollectionViewLayout并实现一个自定义的布局才能达到这个效果。 这需要相当多的工作,实施以下方法: 重写的方法 每个布局对象应该实现以下方法: collectionViewContentSize layoutAttributesForElementsInRect: layoutAttributesForItemAtIndexPath: layoutAttributesForSupplementaryViewOfKind:atIndexPath: (if your layout supports supplementary views) layoutAttributesForDecorationViewOfKind:atIndexPath: (if your layout supports decoration views) shouldInvalidateLayoutForBoundsChange: 然而,我不清楚如何使补充视图在单元格上方浮动,并“粘”到视图的顶部,直到到达下一个部分。 在布局属性中是否有这个标志? 我会使用UITableView但我需要创build一个相当复杂的集合层次结构,这很容易通过集合视图来实现。 任何指导或示例代码将不胜感激!