瀑布流的简单实现
2015-12-17 11:39
253 查看
其实瀑布流就是把 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
重写这个类里面的一些方法
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
相关文章推荐
- c#大圣之路笔记——c# SqlDataReader和SqlDataAdapter区别
- 正则中的顺序环视和逆序环视
- android:ToolBar详解
- 做个程序员到底好不好
- 代码添加控件
- IOS 开发问题解决
- Linux如何查看进程、杀死进程、启动进程等常用命令
- error: field ‘?’ has incomplete type
- 安装Perl语言模块
- 设计模式——面向对象的三大特性
- 十句经典给你坚持的勇气
- Js数组的操作push,pop,shift,unshift等方法详细介绍
- iScroll5的入门
- JavaWeb开发基于Spring和mybatis框架(学习日志)
- NSAttributedString绘制多色镂空字符串
- [VBS] Compare values of two arrays
- 五年后,你的上司可能是机器人
- 程序员整理的各种不错的工具(转)
- 老李分享:HTTP协议之请求和响应
- ssh代理上国外任何网站,ssh教程