Gaurav Sharma
Gaurav Sharma

Reputation: 2770

Prevent UICollectionViewFlowLayout from calculating its own sectionInsets with variable size items

When I specify sectionInsets, for example:

flowLayout.sectionInset = UIEdgeInsetsMake(80, 50, 10, 20);

And all items in my UICollectionView are the same size, the sectionInsets are applied as expected.

When all items in the UICollectionView are not the same size, the sectionInsets are not applied - the flow layout seems to calculate and use its own insets. Is there any way to prevent this behaviour? We'd like the given sectionInset values to hold even with variable item sizes.

Upvotes: 0

Views: 156

Answers (1)

yasirmturk
yasirmturk

Reputation: 1954

Use: - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section;

this delegate methods gets inset for each section not for whole UICollectionView

Upvotes: 1

Related Questions