ZLCollectionView学习

  • 设置几个区

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView;

  • 每个区里有几个item

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section;

  • 每个区的layout类型

- (ZLLayoutType)collectionView:(UICollectionView *)collectionView layout:(ZLCollectionViewFlowLayout *)collectionViewLayout typeOfLayout:(NSInteger)section;

  • 创建每个item的cell,设置cell数据、属性

- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath ;

  • PercentLayout代理,指定每个item的宽度percent。item的宽度percent之和在=1之前不能>1。默认return 1

- (CGFloat)collectionView:(UICollectionView )collectionView layout:(ZLCollectionViewFlowLayout)collectionViewLayout percentOfRow:(NSIndexPath*)indexPath;

  • 每个item的size

- (CGSize)collectionView:(UICollectionView )collectionView layout:(UICollectionViewLayout)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath;

返回数值 Layout枚举 描述
return 宽高 LabelLayout
FillLayout 严格根据size布局
return高 PercentLayout 只需指定size的高度
ClosedLayout 只需指定size的高度,等分width为几份
  • ClosedLayout 设置列数

- (NSInteger)collectionView:(UICollectionView )collectionView layout:(ZLCollectionViewFlowLayout)collectionViewLayout columnCountOfSection:(NSInteger)section;

  • AbsoluteLayout 设置rect

- (CGRect)collectionView:(UICollectionView )collectionView layout:(ZLCollectionViewFlowLayout)collectionViewLayout rectOfItem:(NSIndexPath*)indexPath;

  • AbsoluteLayout 设置zIndex

- (NSInteger)collectionView:(UICollectionView *)collectionView layout:(ZLCollectionViewFlowLayout )collectionViewLayout zIndexOfItem:(NSIndexPath)indexPath;

  • 为每个item设置transform

- (CATransform3D)collectionView:(UICollectionView *)collectionView layout:(ZLCollectionViewFlowLayout )collectionViewLayout transformOfItem:(NSIndexPath)indexPath;

  • 指定上下item的space

- (CGFloat)collectionView:(UICollectionView )collectionView layout:(UICollectionViewLayout)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section;

  • 指定左右item的space

- (CGFloat)collectionView:(UICollectionView )collectionView layout:(UICollectionViewLayout)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section;

  • 指定section内的edgeInset

- (UIEdgeInsets)collectionView:(UICollectionView )collectionView layout:(UICollectionViewLayout)collectionViewLayout insetForSectionAtIndex:(NSInteger)section;

  • 区头也是ReusableView

- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath;

  • 区头size

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section;

  • 区头背景view是这么设置的

- (NSString*)collectionView:(UICollectionView *)collectionView layout:(ZLCollectionViewFlowLayout *)collectionViewLayout registerBackView:(NSInteger)section;

  • 区头view load的时候

- (void)collectionView:(UICollectionView *)collectionView layout:(ZLCollectionViewFlowLayout *)collectionViewLayout loadView:(NSInteger)section;

  • 区头背景颜色

- (UIColor*)collectionView:(UICollectionView *)collectionView layout:(ZLCollectionViewFlowLayout *)collectionViewLayout backColorForSection:(NSInteger)section;

  • 区头背景是否延伸覆盖到区头,默认为NO

- (BOOL)collectionView:(UICollectionView *)collectionView layout:(ZLCollectionViewFlowLayout *)collectionViewLayout attachToTop:(NSInteger)section;

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。