Peter Pik Peter Pik - 24 days ago 9
Swift Question

Setting minimum line spacing in collectionView

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?

i've tried to add the UICollectionViewFlowLayout, but cant since it's a UICollectionViewController.

i guess i need to use something like.

collectionView:layout:minimumLineSpacingForSectionAtIndex:

Answer

Make your UICollectionViewController conform to the protocol UICollectionViewDelegateFlowLayout.

The method you're looking for is:

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section;