Answer the question
In order to leave comments, you need to log in
Why doesn't UICollectionView zIndex work in UICollectionViewLayoutAttributes?
I'm trying to make the very first cell in the collectionView be behind all the others. Even when the next cell overlaps (floats) a little on the first cell
┌──────────┐
│ │
│ Cell 0 │
│┌─────────┴┐
└┤ │
│ Cell 4 │
│ │
└──────────┘
┌──────────┐
│ │
│ Cell 5 │
│ │
└──────────┘
┌──────────┐
│ │
│ Cell 6 │
│ │
└──────────┘
override func prepare() {
super.prepare()
/// Some code
let attributes = UICollectionViewLayoutAttributes(forCellWith: indexPath)
attributes.zIndex = zIndex
/// Some code
}
override func apply(_ layoutAttributes: UICollectionViewLayoutAttributes) {
super.apply(layoutAttributes)
layer.zPosition = CGFloat(layoutAttributes.zIndex)
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question