首页 > 其他 > 详细

瀑布流的简单实现

时间:2015-12-17 12:43:21      阅读:146      评论:0      收藏:0      [点我收藏+]

其实瀑布流就是把 UICollectionViewLayout 这个类写成自己需要的样式,所以我们首先要继承这个类

重写这个类里面的一些方法

1.完成布局信息的预处理

-(void)prepareLayout

2.返回collectionView的内容的尺寸

-(CGSize)collectionViewContentSize

3.当边界发生改变时,是否应该刷新布局。如果YES则在边界变化(一般是scroll到其他地方)时,将重新计算需要的布局信息。

-(BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds

4.返回对应于indexPath的位置的cell的布局属性

-(UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath

5.返回rect中的所有的元素的布局属性

-(NSArray<UICollectionViewLayoutAttributes *> *)layoutAttributesForElementsInRect:(CGRect)rect

效果图:

技术分享

demo链接地址:http://pan.baidu.com/s/1jHgg2Js

 

瀑布流的简单实现

原文:http://www.cnblogs.com/hxwj/p/5053557.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!