UICollectionView-单元格之间的距离? [英] UICollectionView - distance between cells?
本文介绍了UICollectionView-单元格之间的距离?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用单元格宽度为67的UICollectionView,现在我正在使用流布局.
I'm using a UICollectionView with the cell width of 67, right now I am using a flow layout.
我连续有3个单元格,单元格之间有30px的间距.如何减小该距离,以便我可以连续容纳四个单元?这种方法与它有关吗?
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屋!
查看全文