Iglistkit: Question: Inset or spacing aside from interitem spacing

Created on 20 Feb 2017  路  6Comments  路  Source: Instagram/IGListKit

Hi,

I've been searching the issues to see if my question has been previously asked, but I can't seem to find the one need answer for.

I'm developing a tvos app. So my layout is a vertical scroll consisting of horizontal collection view.
Basically similar to the apple Appstore layout.

I need to have an inset for the embedded collection view for the start and the end, which is 100,
and 10 spacing for items. See image below

16833127_120300002227106530_81553827_o

How do I approach this?

I've tried setting the inset for the outer section (the one containing the embedded collectionview), but the scroll will be clipped by bounds. What I need is when scrolled, the items still scroll to the edges of the screen.

question

Most helpful comment

@ninokierulf idea off the top of my head:

  • In the embedded IGListCollectionView, set

    • collectionView.contentInset = UIEdgeInsets(top: 0, left: 100, bottom: 0, right: 90)

  • In each section controller (assuming you're using 1 SC-per-cell), in its initializer, set

    • self.insets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 10)

And that should give you 100 on the left/right with 10 in between. I assume you're using UICollectionViewFlowLayout?

Let us know if that helps!

All 6 comments

@ninokierulf idea off the top of my head:

  • In the embedded IGListCollectionView, set

    • collectionView.contentInset = UIEdgeInsets(top: 0, left: 100, bottom: 0, right: 90)

  • In each section controller (assuming you're using 1 SC-per-cell), in its initializer, set

    • self.insets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 10)

And that should give you 100 on the left/right with 10 in between. I assume you're using UICollectionViewFlowLayout?

Let us know if that helps!

It worked! Thanks

It's much simpler than thinking about indexes.

Love the drawing btw, super helpful 馃槃

I also need to set spacing between embedded horizontal cells, but it doesn't work for me using typical methods minimumInteritemSpacing. Why?
Is there something I maybe don't know?

@jonauz mind opening a separate issue for that? Some things that we also need to know:

  • What layout are you using?
  • What settings are you using for item spacing (on the layout? on section controllers?)

@rnystrom sure, we can if needed.
Eventually I achieved wanted result using this solution.
Thought, still would be curious to understand why minimumInteritemSpacing do no effect on collection view layout.
My layout is exactly as in this picture.

Was this page helpful?
0 / 5 - 0 ratings