KTCenterFlowLayout

Aligns collection view cells to the center of the screen.

Github stars Tracking Chart

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!

Main metrics

Overview
Name With Ownerkeighl/KTCenterFlowLayout
Primary LanguageObjective-C
Program languageObjective-C (Language Count: 2)
Platform
License:MIT License
所有者活动
Created At2014-10-09 19:47:19
Pushed At2021-04-27 10:26:32
Last Commit At2016-12-21 09:30:32
Release Count8
Last Release Name1.3 (Posted on )
First Release Name0.0.1 (Posted on )
用户参与
Stargazers Count456
Watchers Count11
Fork Count58
Commits Count41
Has Issues Enabled
Issues Count23
Issue Open Count5
Pull Requests Count7
Pull Requests Open Count3
Pull Requests Close Count6
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private