Skip to content

imbawales/JWWaterfallLayout

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JWWaterfallLayout

瀑布流布局(封装)

Paste_Image.png

使用方法: 把demo里面的JWWaterFallLayout文件夹拖进项目即可, 然后用JWWaterFallLayout来创建collection view, 可以修改layout的col属性来设置有多少列, 可以遵守数据源代理JWWaterFallLayoutDataSource后用数据源方法来设置每一个cell的高度

示例代码:

JWWaterFallLayout *layout = [[JWWaterFallLayout alloc] init];
layout.minimumLineSpacing = 10;
layout.minimumInteritemSpacing = 10;
layout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);
layout.col = 4; // 设置列数
layout.dataSource = self;
_collectionV = [[UICollectionView alloc] initWithFrame:self.view.bounds collectionViewLayout:layout];

#pragma mark - JWWaterfallLayout DataSource
// 设置每个cell的高度
- (CGFloat)waterfallLayoutWithLayout:(JWWaterFallLayout *)layout itemIndex:(NSInteger)index{
    return arc4random_uniform(100) + 150;
}

About

瀑布流布局(封装)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published