objective-c - 设置UICollectionViewFlowLayout的minimumLineSpacing不起作用怎么回事?

浏览:53日期:2023-11-18

问题描述

UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];

layout.minimumLineSpacing =10.0f; //2.初始化collectionView_homeCollectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, Screen_width , Screen_height - 117) collectionViewLayout:layout];

代码是这样,不知道是什么原因引起minimumLineSpacing属性失效的

问题解答

回答1:

If the delegate object does not implement thecollectionView:layout:minimumLineSpacingForSectionAtIndex: method, theflow layout uses the value in this property to set the spacing betweenlines in a section.

For a vertically scrolling grid, this value represents the minimumspacing between successive rows. For a horizontally scrolling grid,this value represents the minimum spacing between successive columns.This spacing is not applied to the space between the header and thefirst line or between the last line and the footer.

The default value of this property is 10.0.

原因有很多,是否时实现了设置minimumLineSpacing的delegate,还和collectionView的滑动方向有关。

相关文章: