HPCollectionViewWaterfallLayout is inspired by CHTCollectionViewWaterfallLayout and Pinterest, and it's a subclass of UICollectionViewLayout.
It provides a delegate style to config the layout, which is kind of more iOS flavor.
- Support multiple sections with different number of columns
- Use binary search to boost performance
- ARC
- Xcode 4.5+
- iOS 6+
Read the demo codes for detail information.
HPCollectionViewWaterfallLayout *layout = [[HPCollectionViewWaterfallLayout alloc] init];
layout.delegate = self;
####Implement HPCollectionViewDelegateWaterfallLayout
-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout interItemSpaceForSection:(NSUInteger)section;
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath;
-(NSUInteger)collectionView:(UICollectionView*)collectionView layout:(UICollectionViewLayout*)collectionViewLayout numberOfColumnsForSection:(NSUInteger)section;
-(CGFloat)collectionView:(UICollectionView*)collectionView layout:(UICollectionViewLayout*)collectionViewLayout preferredColumnSpaceForSection:(NSUInteger)section;
- Only vertical scrolling is supported.
- No supplementary view and decoration view.
HPCollectionViewWaterfallLayout is available under the MIT license. See the LICENSE file for more info.
Weibo: @Teeeerry大师兄黑曼巴
gmail: hepeng.zhang1