Skip to content

The waterfall (i.e., Pinterest-like) layout for UICollectionView. Inspired by CHTCollectionViewWaterfallLayout, support multiple sections

License

Notifications You must be signed in to change notification settings

hepengzhang/HPCollectionViewWaterfallLayout

Repository files navigation

HPCollectionViewWaterfallLayout

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.

Improvements

  • Support multiple sections with different number of columns
  • Use binary search to boost performance

Screen Shots

2 columns 3 columns

Prerequisite

  • ARC
  • Xcode 4.5+
  • iOS 6+

How to Use

Read the demo codes for detail information.

Setup delegate

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;

Limitation

  • Only vertical scrolling is supported.
  • No supplementary view and decoration view.

License

HPCollectionViewWaterfallLayout is available under the MIT license. See the LICENSE file for more info.

Contact

Weibo: @Teeeerry大师兄黑曼巴

gmail: hepeng.zhang1

About

The waterfall (i.e., Pinterest-like) layout for UICollectionView. Inspired by CHTCollectionViewWaterfallLayout, support multiple sections

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published