GithubHelp home page GithubHelp logo

88oio / chtcollectionviewwaterfalllayout Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chiahsien/chtcollectionviewwaterfalllayout

0.0 2.0 0.0 22.01 MB

The waterfall (i.e., Pinterest-like) layout for UICollectionView.

License: MIT License

Objective-C 75.38% Ruby 0.71% Swift 23.91%

chtcollectionviewwaterfalllayout's Introduction

CHTCollectionViewWaterfallLayout

Version Platform Build Status

CHTCollectionViewWaterfallLayout is a subclass of UICollectionViewLayout, and it trys to imitate UICollectionViewFlowLayout's usage as much as possible.

This layout is inspired by Pinterest. It also is compatible with PSTCollectionView.

Screen Shots

2 columns

Features

  • Easy to use, it trys to imitate UICollectionViewFlowLayout's usage as much as possible.
  • Highly customizable.
  • Outstanding performance, try 10,000+ items and see the smoothness for yourself.
  • Support header and footer views.
  • Different column counts in different sections.

Prerequisite

  • ARC
  • Xcode 4.4+, which supports literals syntax.
  • iOS 6+, or
  • iOS 4.x/5.x, with PSTCollectionView.

How to install

  • CocoaPods
    Add pod 'CHTCollectionViewWaterfallLayout' to your podfile.
  • Manual
    Copy CHTCollectionViewWaterfallLayout.h/m to your project.

How to Use

Read the demo codes and CHTCollectionViewWaterfallLayout.h header file for more information.

Step 1

Below lists the properties for you to customize the layout. Although they have default values, I strongly recommand you to set up at least the columnCount property to suit your needs. The itemRenderDirection property is an enum which decides the order in which your items will be rendered in subsequent rows. For eg. Left-Right | Right-Left | Shortest column filling up first.

@property (nonatomic, assign) NSInteger columnCount;
@property (nonatomic, assign) CGFloat minimumColumnSpacing;
@property (nonatomic, assign) CGFloat minimumInteritemSpacing;
@property (nonatomic, assign) CGFloat headerHeight;
@property (nonatomic, assign) CGFloat footerHeight;
@property (nonatomic, assign) UIEdgeInsets sectionInset;
@property (nonatomic, assign) ItemRenderDirection itemRenderDirection;

Step 2

Your collection view's delegate (which often is your view controller) must conforms to CHTCollectionViewDelegateWaterfallLayout protocol and implements the required method, all you need to do is return the original size of the item:

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath;

Step 3 (Optional)

If you need to support iOS 4.x/5.x and you have installed PSTCollectionView, then you NEED to modify some codes.

Quoted from PSTCollectionView README file:

If you want to have PSTCollectionView on iOS4.3/5.x and UICollectionView on iOS6, use PSUICollectionView (basically add PS on any UICollectionView class to get auto-support for older iOS versions)* If you always want to use PSTCollectionView, use PSTCollectionView as class names. (replace the UI with PST)

Limitation

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

Who is using it

Please let me know if your app is using this library. I'm glad to put your app on the list :-)

  • F3PiX
    F3PiX is a series of apps which gives you a concise, curated collection of pictures by professional (Dutch) photographers according to a specific theme. You can use the pictures freely for your own work.
  • GroupMe for iOS
    GroupMe - A Home for All the Groups in Your Life.
  • Flickr
    Access and organize your photos from anywhere.

License

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

Changelog

Refer to the Releases page.

chtcollectionviewwaterfalllayout's People

Contributors

allevato avatar bb9z avatar bm-i avatar cbowns avatar ccwasden avatar chiahsien avatar ddwang avatar demonnico avatar dlackty avatar flagoworld avatar jamztang avatar jstnheo avatar krzd avatar mli-eventbrite avatar neilkimmett avatar olivercameron avatar przytua avatar scorpionking2k5 avatar sfader avatar timkettering avatar wcbyrne avatar zdavison avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.