我试图实现的效果是一种粘性标题单元格.对我来说,粘性细胞漂浮在其他细胞的顶部是很重要的.有点像这样:
????????????
? ?
? Cell 0 ?
? ??
?????????????
? Cell 4 ?
? ?
????????????
????????????
? ?
? Cell 5 ?
? ?
????????????
????????????
? ?
? Cell 6 ?
? ?
????????????
Run Code Online (Sandbox Code Playgroud)
单元格4,5和6通常是可见的,我正在构建UICollectionViewFlowLayout子类中单元格0的属性layoutAttributesForElementsInRect:.我所做的只是调用超级实现,确定我需要添加哪个单元格然后构造UICollectionViewLayoutAttributes(forCellWithIndexPath:).然后我将zIndex它设置为1(默认为0).
我得到的问题是UICollectionView似乎总是忽略了zIndex
????????????
? ?
? Cell 0 ?
?????????????
?? ?
? Cell 4 ?
? ?
????????????
????????????
? ?
? Cell 5 ?
? …Run Code Online (Sandbox Code Playgroud)