UICollectionView - 单元格之间的距离? [英] UICollectionView - distance between cells?

查看:16
本文介绍了UICollectionView - 单元格之间的距离?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是单元格宽度为 67 的 UICollectionView,现在我使用的是流式布局.

I'm using a UICollectionView with the cell width of 67, right now I am using a flow layout.

我连续有 3 个单元格,单元格之间的间距为 30 像素.如何使该距离更小,以便我可以连续放置四个单元格?这个方法和它有关系吗?

I have 3 cells in a row with 30px space between cells. How can make that distance less, so that I can fit four cells in a row? Does this method have something to do with it?

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

推荐答案

这个 UICollectionViewFlowLayoutDelegate 方法会帮助你..

This UICollectionViewFlowLayoutDelegate method will help you..

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionView *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section  
  {
    return 10; // This is the minimum inter item spacing, can be more
  }

如果您需要更多空间来排列单元格,还可以调整 edgeInsets

One more if you need more space to arrange your cells adjust the edgeInsets also

这篇关于UICollectionView - 单元格之间的距离?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆