- (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds;

-- (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds{

return NO;

}

判定为布局需要被无效化并重新计算的时候,布局对象会被询问以提供新的布局。


 2.- (void)prepareLayout 系统在准备对item进行布局前会调用这个方法,我们重写这个方法之后可以在方法里面预先设置好需要用到的变量属;

3.

 - (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect
为所有item返回一个layout attributes数组,数组中元素的类型为UICollectionViewLayoutAttributes。UICollectionViewLayoutAttributes记录了一个layout的位置、大小、透明度等信息。

4.

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

为一个特定的item返回layout attribute。注意,返回的attribute仅使用cell,不包括supplementary view和decoration view。


你可能感兴趣的:(oc)