ios UICollectionView简单说明

原谅我记不住写下来好了ide

UICollectionViewFlowLayout 流式自动布局 继承于UICollectionViewLayout布局

初始化:[[UICollectionViewFlowLayout alloc]init]代理

属性说明:继承

  minimumLineSpacing:cell上下间距ci

  minimumInteritemSpacing:左右间距it

  itemSize:cell的sizeio

  scrollDirection:方向class

  sectionInset:模块的边距scroll

  headerReferenceSize:heder尺寸im

  footerReferenceSize:footer尺寸

UICollectionView 集合视图

初始化:[[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) collectionViewLayout:flowLayout];

注册cell:[_collectionView registerClass:[CollectionViewCell class] forCellWithReuseIdentifier:@"CollectionViewCell"];

     registerNib:(nullable UINib *)nib forCellWithReuseIdentifier:(NSString *)identifier(xib)
注册reusableView:[_collectionView registerClass:[CollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"reusableView"];

          registerNib:(nullable UINib *)nib forSupplementaryViewOfKind:(NSString *)kind withReuseIdentifier:(NSString *)identifier;

经常使用代理:UICollectionViewDataSource

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

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

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

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

 

      UICollectionViewDelegate

     - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath

 

     UICollectionViewDelegateFlowLayout

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

 推荐:UICollectionViewLeftAlignedLayout 使其左对齐 

相关文章
相关标签/搜索