iOS -collectionview的间距方法

//单元格大小

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

{

    return CGSizeMake((SCREEN_WIDTH-60)/3.0,(SCREEN_WIDTH-60)/3.0);

}


//定义每个section四边间距

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

{

    return UIEdgeInsetsMake(15, 15,15,15);

}

扫描二维码关注公众号,回复: 2430213 查看本文章


//两行cell之间的间距

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

{

    return 15.0f;

}


//同一行两个cell的间距

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

{

    return 15.0f;

}

猜你喜欢

转载自blog.csdn.net/qq_27979381/article/details/80736434
今日推荐