自定义集合视图悬停效果

时间:2018-01-19 05:39:31

标签: ios swift

我们可以在特定单元格上设置集合悬停效果吗? 如下图所示,我将第5个单元格设置为悬停,但如图所示如何在第5个单元格后面设置第6个单元格?

enter image description here

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
}

0 个答案:

没有答案