iosiglistkit

IGListKit - Dynamic .minimumLineSpacing within a IGListSectionController


I have a section controller "mySectionController" with 3 different cells inside

I want to apply .minimumLineSpacing only between cell B and C

If I set the .minimumLineSpacing in the init of my controller, obviously the space is applied to all my cells.

I could add a space in my B cell, but i was looking for a clean solution.

Is it possible?


Solution

  • I'd probably recommend adding 10pts of spacing to your actual cell in this case. Create a sizing class function on your cell that returns the preferred size + 10, then in layoutSubviews just subtract 10 from the bounds height.

    UICollectionViewFlowLayout isn't designed to have variable line spacing, so we modeled IGListKit after that:

    https://github.com/Instagram/IGListKit/blob/master/Source/IGListAdapter.m#L1167-L1170

    It wouldn't be impossible to write your own layout and hook into IGListKit to make this work, however I think using the cell padding "trick" above would be a whole lot simpler.