KTCenterFlowLayout

by keighl

Aligns collection view cells to the center of the screen.

446 Stars 56 Forks Last release: Not found MIT License 41 Commits 8 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

KTCenterFlowLayout

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:

Horizontal Scrolling

This layout doesn't work with

UICollectionViewScrollDirection.horizontal
.

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!

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.