Need help with KTCenterFlowLayout?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

keighl
446 Stars 56 Forks MIT License 41 Commits 7 Opened issues

Description

Aligns collection view cells to the center of the screen.

Services available

!
?

Need anything else?

Contributors list

# 233,619
Objecti...
Ruby
iOS
15 commits
# 173,014
materia...
Shell
Objecti...
JavaScr...
2 commits
# 10,710
Swift
Objecti...
Xcode
spm
1 commit
# 492,823
Objecti...
Ruby
iOS
1 commit
# 500,091
Objecti...
Ruby
iOS
1 commit

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.