UICollectionViewLayout
来源:互联网 发布:王阳明 知乎 编辑:程序博客网 时间:2024/05/16 05:01
重写prepareLayout方法
- 作用:在这个方法中做一些初始化操作
- 注意:一定要调用[super prepareLayout]
- 重新替换UICollectionViewLayout的时候回调用这个方法
重写layoutAttributesForElementsInRect:方法
- 作用:
- 这个方法的返回值是个数组
- 这个数组中存放的都是UICollectionViewLayoutAttributes对象
- UICollectionViewLayoutAttributes对象决定了cell的排布方式(frame等)
重写shouldInvalidateLayoutForBoundsChange:方法
- 作用:如果返回YES,那么collectionView显示的范围发生改变时,就会重新刷新布局
- 一旦重新刷新布局,就会按顺序调用下面的方法:
- prepareLayout
- layoutAttributesForElementsInRect:
重写targetContentOffsetForProposedContentOffset:withScrollingVelocity:方法
- 作用:返回值决定了collectionView停止滚动时最终的偏移量(contentOffset)
参数:
- proposedContentOffset:原本情况下,collectionView停止滚动时最终的偏移量
- velocity:滚动速率,通过这个参数可以了解滚动的方向
layoutAttributesForItemAtIndexPath:方法不一定要重写,当删除的时候或者重新刷新的时候会调用
0 0
- UICollectionViewLayout
- UICollectionViewLayout
- UICollectionViewLayout
- UICollectionViewLayout
- UICollectionViewLayout
- UICollectionViewLayout
- UICollectionViewLayout
- UICollectionViewLayout
- UICollectionViewLayout
- UICollectionViewLayout
- UICollectionViewLayout
- UICollectionViewLayout
- UICollectionViewLayout
- UICollectionViewLayout
- UICollectionViewLayout
- UICollectionViewLayout
- UICollectionViewLayout
- UICollectionViewLayout
- UE4控制灯光开关
- POJ 2528 Mayor's posters -
- 简单的订阅者/发布者模式
- 二叉树的序号(poj 二叉树)
- 欢迎来到本人iOS博客
- UICollectionViewLayout
- JavaScript设计模式----策略模式
- 块元素和行内元素比较
- LintCode:整数排序
- 动态链接库的优缺点
- android测试类
- 剑指offer面试题:求二叉树的镜像(递归、循环解法及测试用例)
- 在 Cent OS 7 上搭建带着 PHP 7 和 Memcached 的 LAMP
- HDU4349->Lucas定理