Skip to content

mhxue/MHCollectionViewFlowLayout

Repository files navigation

MHCollectionViewFlowLayout

CI Status Version License Platform

Screenshots

demo.png
demo

Feature

  1. Set different layout for each section.
- (MHCollectionViewFlowLayoutType)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout layoutTypeForSectionAtIndex:(NSInteger)section;
  1. Current suport flow and water fall layout method.
typedef NS_ENUM(NSUInteger, MHCollectionViewFlowLayoutType) {
    MHCollectionViewFlowLayoutTypeFlow,
    MHCollectionViewFlowLayoutTypeWaterFall,
};
  1. Respect the exact line and interitem spacing you set versus the UIKit default behavior.
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout lineSpacingForSectionAtIndex:(NSInteger)section;
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout interitemSpacingForSectionAtIndex:(NSInteger)section;

Attention

For MHCollectionViewFlowLayoutTypeWaterFall layout, the number of columns and the width of each column is decided by the itemSize you returned by - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath; for the first row. Once the first row is fullfilled, the subsequent items' width you returned from the delegate method is ignored.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

MHCollectionViewFlowLayout is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'MHCollectionViewFlowLayout', :git => 'git@github.com:Minghao2017/MHCollectionViewFlowLayout.git'

Author

薛明浩, xue_minghao@qq.com

License

MHCollectionViewFlowLayout is available under the MIT license. See the LICENSE file for more info.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published