Coder Social home page Coder Social logo

tadeaskriz / selfsizingwaterfallcollectionviewlayout Goto Github PK

View Code? Open in Web Editor NEW

This project forked from adamwaite/selfsizingwaterfallcollectionviewlayout

1.0 3.0 0.0 20.58 MB

SelfSizingWaterfallCollectionViewLayout is a UICollectionViewLayout subclass that organizes items of dynamic height into a grid of variable columns (as if you're winning at Tetris upside-down). Designed for use alongside AutoLayout and iOS8 self-sizing cell technologies.

License: MIT License

Objective-C 96.07% Ruby 3.93%

selfsizingwaterfallcollectionviewlayout's Introduction

SelfSizingWaterfallCollectionViewLayout

SelfSizingWaterfallCollectionViewLayout is a UICollectionViewLayout subclass that organises items of dynamic height into a grid of variable columns. Items flow from one row or column to the next, with each item being placed beneath the shortest column in the section (as if you're winning at Tetris upside-down). It supports multiple sections, headers and footers. It's designed to be used alongside AutoLayout and self-sizing cell technologies introduced in iOS8.

💀 SelfSizingWaterfallCollectionViewLayout is an Objective-C project and is no longer maintained. Thanks to all contributors!

demo-vid

Integration

pod 'SelfSizingWaterfallCollectionViewLayout'

API

The API has been designed to replicate UICollectionViewFlowLayout so it should be familiar. There are a few additions to support variable columns and waterfall design.

Properties

Section insets

@property (nonatomic) UIEdgeInsets sectionInset;

The margins used to lay out content in a section. Default: UIEdgeInsetsZero.

Number of columns

@property (nonatomic) NSUInteger numberOfColumns;

The number of columns in the layout. Default: 2. Use the SelfSizingWaterfallCollectionViewLayoutDelegate delegate method to specify a different variable number of columns between sections.

Inter-item spacing

@property (nonatomic) CGFloat minimumInteritemSpacing;

The minimum spacing to use between items in the same row. Default: 8.0f;

Line spacing

@property (nonatomic) CGFloat minimumLineSpacing;

The minimum spacing to use between lines of items in the layout. Default: 8.0f;

Header size

@property (nonatomic) CGSize headerReferenceSize;

The size for collection view headers. Default: CGSizeZero;

Footer size

@property (nonatomic) CGSize footerReferenceSize;

The size for collection view footers. Default: CGSizeZero;

Estimated item height

@property (nonatomic) CGFloat estimatedItemHeight;

An estimate for an item’s height for use in a preliminary layout. A value returned by preferredLayoutAttributesFittingAttributes: in a UICollectionViewCell will take precedence over this value.

SelfSizingWaterfallCollectionViewLayoutDelegate

An object conforming to SelfSizingWaterfallCollectionViewLayoutDelegate may provide layout information for a SelfSizingWaterfallCollectionViewLayout instance. All of the methods in this protocol are optional. If you do not implement a particular method, the layout will fall back to use values in its own properties for the appropriate layout information.

The self sizing waterfall layout object expects the collection view’s delegate object to adopt this protocol (as with UICollectionViewDelegateFlowLayout).

Section insets

- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section;

Asks the delegate for the margins to apply to content in the specified section.

Number of columns in section

- (NSUInteger)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout numberOfColumnsInSection:(NSUInteger)section;

Asks the delegate how many columns a section should contain.

Inter-item spacing

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section;

Asks the delegate for the horizontal spacing between columns.

Line spacing

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section;

Asks the delegate for the vertical spacing between successive items in a column of a section.

Header size

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSUInteger)section;

Asks the delegate for the size of the header view in the specified section.

Footer size

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForFooterInSection:(NSUInteger)section;

Asks the delegate for the size of the footer view in the specified section.

Estimated item height

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout estimatedHeightForItemAtIndexPath:(NSIndexPath *)indexPath;

Asks the delegate for an estimate of the height of the specified item’s cell for a preliminary layout pass.

Contact

@adamwaite

##License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

selfsizingwaterfallcollectionviewlayout's People

Contributors

adamwaite avatar

Stargazers

Roman avatar

Watchers

Tadeas Kriz avatar James Cloos 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.