Simple implementation of waterfall stream and simple implementation of waterfall stream
In fact, the waterfall stream is to write the class UICollectionViewLayout as the style you need, so we must first inherit this class
Override some methods in this class
1. Complete layout information preprocessing
-(Void) prepareLayout
2. Return the size of collectionView content
-(CGSize) collectionViewContentSize
3. Whether to refresh the layout when the border changes. If YES, the layout information is recalculated when the boundary changes (generally scroll to another place.
-(BOOL) shouldInvalidateLayoutForBoundsChange :( CGRect) newBounds
4. Return the layout attribute of the cell corresponding to the location of indexPath.
-(UICollectionViewLayoutAttributes *) layoutAttributesForItemAtIndexPath :( NSIndexPath *) indexPath
5. Return the layout attributes of all elements in the rect.
-(NSArray <UICollectionViewLayoutAttributes *> *) layoutAttributesForElementsInRect :( CGRect) rect
:
Demo link: http://pan.baidu.com/s/1jHgg2Js