Latest 0.1
Homepage https://github.com/yoeriboven/TopAlignedCollectionViewLayout
License MIT
Platforms ios 6.0, requires ARC
Authors

TopAlignedCollectionViewLayout

With this UICollectionViewFlowLayout subclass, your UICollectionView looks like a UITableView if you are using cells with dynamic heights.

If items on a row have different heights, the row will get the same height as the biggest item on the row. The smaller items will then center on the y-axis. With YBTopAlignedCollectionViewFlowLayout, all items will be aligned at the top.

Gif example.

How to use

Using YBTopAlignedCollectionViewFlowLayout is very easy:

Add the pod YBTopAlignedCollectionViewFlowLayout to your Podfile or manually download the files and add them to your project.

#import "YBTopAlignedCollectionViewFlowLayout.h"

Now where you would create the UICollectionViewFlowLayout do this:

YBTopAlignedCollectionViewFlowLayout *layout = [[YBTopAlignedCollectionViewFlowLayout alloc] initWithNumColumns:3];
layout.delegate = self;

Don’t forget to implement the delegate.

@interface MyViewController : UIViewController <UICollectionViewDelegateFlowLayout>

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath;
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section;

Requirements

YBTopAlignedCollectionViewFlowLayout requires iOS 6.0 or greater.

The example project only works with iOS 7

License

Usage is provided under the MIT License. See LICENSE for the full details.

Latest podspec

{
    "name": "YBTopAlignedCollectionViewFlowLayout",
    "version": "0.1",
    "summary": "With this UICollectionViewFlowLayout subclass, your UICollectionView looks like a UITableView if you are using cells with dynamic heights.",
    "homepage": "https://github.com/yoeriboven/TopAlignedCollectionViewLayout",
    "screenshots": "https://camo.githubusercontent.com/c92629aa56e010c7ccdd114629f5d0d96b5ffa82/687474703a2f2f6935382e74696e797069632e636f6d2f31337a6d68796f2e676966",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Yoeri Boven": "[email protected]"
    },
    "social_media_url": "http://twitter.com/yoeriboven",
    "source": {
        "git": "https://github.com/yoeriboven/TopAlignedCollectionViewLayout.git",
        "tag": "0.1"
    },
    "platforms": {
        "ios": "6.0"
    },
    "source_files": "YBTopAlignedCollectionViewFlowLayout/YBTopAlignedCollectionViewFlowLayout.{h,m}",
    "requires_arc": true
}

Pin It on Pinterest

Share This