I'm trying to set the minimum line spacing using swift in my collectionViewController, but i can't seem too find the method i need to use. I need this to be programmatically since i need to change this dynamically depending on the selectedSegmentedIndex. How can i change the minimum line spacing programmatically?
我试图在我的collectionViewController中使用swift设置最小行间距,但我似乎无法找到我需要使用的方法。我需要这个以编程方式,因为我需要根据selectedSegmentedIndex动态更改它。如何以编程方式更改最小行间距?
i've tried to add the UICollectionViewFlowLayout, but cant since it's a UICollectionViewController.
我试图添加UICollectionViewFlowLayout,但不能,因为它是一个UICollectionViewController。
i guess i need to use something like.
我想我需要使用类似的东西。
collectionView:layout:minimumLineSpacingForSectionAtIndex:
2 个解决方案
#1
23
Make your UICollectionViewController
conform to the protocol UICollectionViewDelegateFlowLayout
.
使您的UICollectionViewController符合协议UICollectionViewDelegateFlowLayout。
The method you're looking for is:
您正在寻找的方法是:
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section;
- (CGFloat)collectionView:(UICollectionView *)collectionView布局:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section;
#2
5
Swift:
迅速:
func collectionView(collectionView: UICollectionView, layout
collectionViewLayout: UICollectionViewLayout,
minimumLineSpacingForSectionAtIndex section: Int) -> CGFloat {
return 1.0
}
#1
23
Make your UICollectionViewController
conform to the protocol UICollectionViewDelegateFlowLayout
.
使您的UICollectionViewController符合协议UICollectionViewDelegateFlowLayout。
The method you're looking for is:
您正在寻找的方法是:
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section;
- (CGFloat)collectionView:(UICollectionView *)collectionView布局:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section;
#2
5
Swift:
迅速:
func collectionView(collectionView: UICollectionView, layout
collectionViewLayout: UICollectionViewLayout,
minimumLineSpacingForSectionAtIndex section: Int) -> CGFloat {
return 1.0
}