×

GXWaterCollectionViewLayout可设置纵横方向和排列数的瀑布流布局

消耗积分:0 | 格式:zip | 大小:1.45 MB | 2022-06-24

小峰

分享资料个

授权协议 MIT
开发语言 Objective-C
操作系统 跨平台
软件类型 开源软件

软件简介

GXWaterCollectionViewLayout 是一个好用的瀑布流布局,可以设置纵横方向和排列数等。

Requirements

  • iOS 7.0 or later

  • Xcode 8.0 or later

Usage in you Podfile:

pod 'GXWaterCollectionViewLayout'

 

可以设置纵横方向

@property (nonatomic, assign) UICollectionViewScrollDirection scrollDirection;  //滚动方向

可以设置的其它参数

@property (nonatomic, assign) NSInteger    numberOfColumns;   //瀑布流横排数
@property (nonatomic, assign) CGFloat      lineSpacing;       //纵向间距
@property (nonatomic, assign) CGFloat      interitemSpacing;  //横向间距
@property (nonatomic, assign) CGSize       headerSize;        //页眉尺寸
@property (nonatomic, assign) CGSize       footerSize;        //页脚尺寸
@property (nonatomic, assign) UIEdgeInsets sectionInset;      //分类inset

实例应用代码

// 初始化瀑布流布局
self.waterLayout = [[GXWaterCollectionViewLayout alloc] init];
self.waterLayout.numberOfColumns = 4;
self.waterLayout.lineSpacing = 10.0;
self.waterLayout.interitemSpacing = 10.0;
self.waterLayout.sectionInset = UIEdgeInsetsMake(20, 20, 20, 20);
self.waterLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
self.waterLayout.headerSize = CGSizeMake(self.view.bounds.size.width, 40);
self.waterLayout.footerSize = CGSizeMake(self.view.bounds.size.width, 40);
self.waterLayout.delegate = self;
// 初始化UICollectionView
self.waterCollectionView = [[UICollectionView alloc] initWithFrame:self.view.bounds collectionViewLayout:self.waterLayout];
self.waterCollectionView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
self.waterCollectionView.backgroundColor = [UIColor whiteColor];
self.waterCollectionView.delegate = self;
self.waterCollectionView.dataSource = self;
[self.view addSubview:self.waterCollectionView];

方向UICollectionViewScrollDirectionVertical效果

 

 

声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

评论(0)
发评论

下载排行榜

全部0条评论

快来发表一下你的评论吧 !