MZFreeLayout
简介
MZFreeLayout 的 Swift 版本
自定义 UICollectionView 的 Layout,实现类似 Excel 的功能。
安装方法
在 podfile 中添加以下语句
pod 'MZFreeLayout', '~> 1.0.0'
用法
例如。
在已知表格样式的前提下,按从左到右,从上到下,依次添加索引,已编号的跳过,参考上图的索引规则
1.引入头文件
#import "MZFreeLayout.h"
2.设置代理
MZFreeLayout *freeLayout = [[MZFreeLayout alloc] init];
freeLayout.delegate = self;
3.需要实现的主要代理方法
#pragma mark - MZFreeSheetLayoutDelegate
- (CGFloat)baseWidthOfCollectionView:(UICollectionView *)collectionView cellWidthOf:(NSInteger)index {
return 40;
}
- (CGFloat)baseHeightOfCollectionView:(UICollectionView *)collectionView cellHeightOf:(NSInteger)index {
return 50;
}
- (MZFreeModel *)scaleOfCollectionView:(UICollectionView *)collectionView {
return [MZFreeModel initWithX:20 Y:20];
}
- (MZFreeModel *)mzCollectionView:(UICollectionView *)collectionView cellSizeOfIndex:(NSInteger)index {
return [MZFreeModel initWithX:1 Y:1];
}
- (MZFreeModel *)frozenUnitOfCollection:(UICollectionView *)collectionView {
return [MZFreeModel initWithX:0 Y:1];
}
#pragma mark - UICollectionViewDataSource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return 400;
}
版本更新历史
版本号 | 版本描述 |
---|---|
0.1.0 | 从 MZMultiHeadersSheet 库分离出来 |
1.0.0 | 更换单元格宽度和高度的代理 |
作者
开源证书
MZFreeLayout遵循MIT许可协议。更多信息请参阅LICENSE文件。