Peter Pik Peter Pik - 11 months ago 84
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.


Answer Source

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;