一、案例演示
本案例演示的是每个cell都有一点倾斜角度的效果,如下图所示:
二、知识储备
2.1、如何让CELL倾斜
其实 layoutAttributes 已经为我们提供了 transform 属性,我们可以使用这个属性来实现旋转。
关键代码示例:
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect{
NSArray *attributes = [super layoutAttributesForElementsInRect:rect];
for (UICollectionViewLayoutAttributes *attr in attributes ) {
CGFloat degrees = M_PI * (-14.0f/180.0f);
attr.transform = CGAffineTransformMakeRotation(degrees);
}
return attributes;
}
三、Demo下载地址
Demo下载地址
如果对你有点帮助,star一下吧。
四、联系方式
微博:新浪微博
博客:http://blog.csdn.net/yixiangboy
github:https://github.com/yixiangboy