Giter VIP home page Giter VIP logo

asjcollectionviewfilllayout's Introduction

ASJCollectionViewFillLayout

The standard available UICollectionViewLayout does the job well, but the UI may look asymmetric, depending on the number of items the UICollectionView is displaying. This library attempts to solve this problem. This is a UICollectionViewLayout subclass that fills the full width of the collection view.

Installation

CocoaPods is the preferred way to install this library. Add this command to your Podfile:

pod 'ASJCollectionViewFillLayout'

If you prefer the classic way, just copy the ASJCollectionViewFillLayout folder (.h and .m files) to your project.

Usage

Creating an ASJCollectionViewFillLayout is easy. It has a simple interface consisting of three properties. You can also use the traditional delegate pattern to return the attributes you wish to use. All are optional.

@property (assign, nonatomic) NSInteger numberOfItemsInRow;

Sets the number of items to show in one row.

@property (assign, nonatomic) CGFloat itemHeight;

Sets the height of an item. The width will be calculated to fill the view.

@property (assign, nonatomic) CGFloat itemSpacing;

Sets the distance between two collection view items.

For example:

ASJCollectionViewFillLayout *aFillLayout = [[ASJCollectionViewFillLayout alloc] init];
aFillLayout.numberOfItemsInRow = 3;
aFillLayout.itemSpacing = 5.0f;
aFillLayout.itemHeight = 75.0f;
aCollectionView.collectionViewLayout = aFillLayout;

See the example project for a demonstration of how to use the delegate pattern.

alt tag alt tag

Credits

To-do

  • Handle case of total collection view items being less than the number of items in one row.
  • Add option for horizontal direction; try subclassing UICollectionViewFlowLayout itself.

License

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

asjcollectionviewfilllayout's People

Contributors

readmecritic 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.