GithubHelp home page GithubHelp logo

nerdsrob / uicollectionviewwaterfalllayout Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chiahsien/chtcollectionviewwaterfalllayout

0.0 1.0 0.0 2.26 MB

The waterfall (i.e., Pinterest-like) layout for UICollectionView introduced in iOS 6.

License: MIT License

uicollectionviewwaterfalllayout's Introduction

UIWaterfallLayout

iOS 6 introduced a new feature called UICollectionView. UIWaterfallLayout is a subclass of UICollectionViewLayout.

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

Screen Shots

2 columns 3 columns

Prerequisite

  • ARC
  • Xcode 4.4+, which supports literals syntax.
  • iOS 6+, or
  • iOS 5 and below, with PSTUICollectionView.

How to Use

Step 1

There are four properties for you to set up.

@property (nonatomic, weak) id<UICollecitonViewDelegateWaterfallLayout> delegate;
@property (nonatomic, assign) NSUInteger columnCount; // How many columns
@property (nonatomic, assign) CGFloat itemWidth; // Width for every column
@property (nonatomic, assign) UIEdgeInsets sectionInset; // The margins used to lay out content in a section

It's your responsibility to set up delegate, columnCount, and itemWidth, they are required. But sectionInset is optional.

Step 2

And you also need to implement a method for the UICollecitonViewDelegateWaterfallLayout protocol.

- (CGFloat)collectionView:(UICollectionView *)collectionView
                   layout:(UICollectionViewWaterfallLayout *)collectionViewLayout
 heightForItemAtIndexPath:(NSIndexPath *)indexPath;

Then you are done! Easy, right?

Limitation

  • Only one section is supported.

License

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

Known Issue

None, so far.

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.