在何处/如何为此单元格布局行为编写代码。
我需要每个细胞重叠以前的。
细胞2 centerX是细胞1的右边缘,等等.

在我的自定义UICollectionViewLayout中,我要重写什么方法?
发布于 2017-07-09 05:04:57
创建自定义collectionView布局时,重写layoutAttributesForItem以配置单元格布局行为.
var preferredSize: CGSize? = CGSize(width: 100, height: 100)
override func layoutAttributesForItem(at indexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
let attributes = UICollectionViewLayoutAttributes(forCellWith: indexPath)
attributes.size = preferredSize!
//Modifying the centerX property adjust the overlapping effect
let centerX = (preferredSize?.width)! / 2.0 + CGFloat(indexPath.item) * ((preferredSize?.width)! * 0.5 )
let centerY = collectionView!.bounds.height / 2.0
attributes.center = CGPoint(x: centerX, y: centerY)
attributes.zIndex = -(indexPath.item)
return attributes
}https://stackoverflow.com/questions/44957559
复制相似问题