YHWaterFallLayout
瀑布流简易使用
示例
安装
CocoaPods (推荐)
- 编辑你的
Podfile.
pod 'YHWaterFallLayout', :git => 'https://github.com/yelinux/YHWaterFallLayout.git'
- 执行
pod install或pod update.
手动集成
- 拖动文件夹
YHWaterFallLayout到你的项目.
Usage
- 引用头文件:
#import "YHWaterFallLayout.h"
- 创建collectionViewLayout实例:
YHWaterFallLayout
YHWaterFallLayout *layout = [[YHWaterFallLayout alloc] init];
layout.minimumLineSpacing = 5;
layout.minimumInteritemSpacing = 5;
layout.sectionInset = UIEdgeInsetsMake(8, 8, 8, 8);
layout.delegate = self;
UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:self.view.bounds collectionViewLayout:layout];
- 配置delegate:
YHWaterFallLayoutDelegate
//@optional
-(CGSize)yHWaterFallLayout:(YHWaterFallLayout *)layout sizeForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
if ([kind isEqualToString:UICollectionElementKindSectionHeader]) {
} else {
}
}
//@required
-(CGSize)yHWaterFallLayout:(YHWaterFallLayout *)layout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
}
- 配置 UICollectionView's delegate 和 datasource:
UICollectionViewDelegate, UICollectionViewDataSource
//@optional
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
}
//@optional
-(UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
}
//@required
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
}
//@required
-(__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
}