项目作者: zhuyunfeng1224

项目描述 :
一个基于UICollectionViewFlowLayout的瀑布流布局
高级语言: Objective-C
项目地址: git://github.com/zhuyunfeng1224/XHWaterfallFlowLayout.git
创建时间: 2016-09-08T03:06:46Z
项目社区:https://github.com/zhuyunfeng1224/XHWaterfallFlowLayout

开源协议:MIT License

下载


一个基于UICollectionViewFlowLayout的瀑布流布局 用于UICollectionView
经常做电商产品展示,需要用到瀑布流,这里整理下和大家分享~

image

使用方法

实现XHWaterfallFlowLayoutDelegate代理,并实现其中方法

- (CGFloat)getHeightExceptImageAtIndex:(NSIndexPath *)indexPath;
这个方法是返回除图片以外的高度

- (CGFloat)getImageRatioOfWidthAndHeight:(NSIndexPath *)indexPath;
这个方法返回图片宽高比例0-1

使用XHWaterfallFlowLayout同UICollectionViewFlowLayout

  1. _flowLayout = [[XHWaterfallFlowLayout alloc] init];
  2. _flowLayout.columnCount = 2; // 显示列数
  3. _flowLayout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);
  4. _flowLayout.minimumInteritemSpacing = 10;
  5. _flowLayout.minimumLineSpacing = 10;
  6. _flowLayout.sDelegate = self;

导入

手工导入

下载或clone到本地,导入XHWaterfallFlowLayout.h和XHWaterfallFlowLayout.m文件即可
内含demo

cocoapods导入

pod 'XHWaterfallFlowLayout', '~> 1.0.0'

License

MIT license.