Latest 1.3.1
Homepage https://github.com/keighl/KTCenterFlowLayout
License MIT
Platforms ios 7.0, tvos 9.0, requires ARC
Frameworks UIKit
Authors

[CocoaPods]()

KTCenterFlowLayout is a subclass of UICollectionViewFlowLayout which Aligns cells to the center of a collection view. It effectively enforces the minimumInteritemSpacing.

Usage

# In your Podfile

pod 'KTCenterFlowLayout'

Objective-C:

KTCenterFlowLayout *layout = [KTCenterFlowLayout new];
layout.minimumInteritemSpacing = 10.f;
layout.minimumLineSpacing = 10.f;

[[UICollectionViewController alloc] initWithCollectionViewLayout:layout];

Swift:

let layout = KTCenterFlowLayout()
layout.minimumInteritemSpacing = 10.0
layout.minimumLineSpacing = 10.0

UICollectionViewController(collectionViewLayout: layout)

Example

See the layout in use in the ./Example app:

Self-sizing cells

This layout doesn’t work with self-sizing collection view cells (estimatedItemSize). Of course, neither does the vanilla UICollectionViewFlowLayout. Pull requests appreciated from anybody interested in solving self-sizing layouts!

Latest podspec

{
    "name": "KTCenterFlowLayout",
    "version": "1.3.1",
    "summary": "Aligns cells to the center of a collection view.",
    "homepage": "https://github.com/keighl/KTCenterFlowLayout",
    "license": "MIT",
    "authors": {
        "keighl": "[email protected]"
    },
    "source": {
        "git": "https://github.com/keighl/KTCenterFlowLayout.git",
        "tag": "1.3.1"
    },
    "social_media_url": "https://twitter.com/keighl",
    "platforms": {
        "ios": "7.0",
        "tvos": "9.0"
    },
    "requires_arc": true,
    "source_files": "KTCenterFlowLayout.{h,m}",
    "frameworks": "UIKit"
}

Pin It on Pinterest

Share This