我有UICollectionView,我想在其中的单元格之间没有间距。但是,尽管我全力以赴,但我似乎无法移开空白处,

代码

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section
{
    return 0;
}

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
{
    return 0;
}

- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
    return UIEdgeInsetsMake(0, 0, 0, 0);
}

额外信息
  • 单元格宽度为234
  • UICollectionView的宽度为703
  • 最佳答案

    this
    您需要更改minimumInteritemSpacing和minimumLineSpacing。

    UICollectionViewFlowLayout *flow = [[UICollectionViewFlowLayout alloc] init];
    flow.itemSize = CGSizeMake(cellWidth, cellHeight);
    flow.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    flow.minimumInteritemSpacing = 0;
    flow.minimumLineSpacing = 0;
    mainCollectionView.collectionViewLayout = flow;
    

    关于ios - 如何删除两个UICollectionView列之间的边距,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21281462/

    10-12 18:54