我们可以在特定单元格上设置集合悬停效果吗? 如下图所示,我将第5个单元格设置为悬停,但如图所示如何在第5个单元格后面设置第6个单元格?
override func layoutAttributesForItem(at indexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
let attributes = UICollectionViewLayoutAttributes(forCellWith: indexPath)
attributes.size = preferredCellSize
var centerX : CGFloat? = 0
if indexPath.item >= 5 {
centerX = preferredCellSize.width / 2.0 + CGFloat(indexPath.item) * (centerDiff) + 20.0
} else {
centerX = preferredCellSize.width / 2.0 + CGFloat(indexPath.item) * centerDiff
}
let centerY = collectionView!.bounds.height / 2.0
attributes.center = CGPoint(x:centerX!, y:centerY)
attributes.zIndex = indexPath.item
return attributes
}