5

I'm creating UICollectionViewCompositionalLayout with NSCollectionLayoutSection. I have section with assigned header. Setting contentInsets on section works as expected but setting contentInsets on header works only for horizontal alignment (leading and trailing are ok). The problem is that top and bottom insets are not working for header. Section has supplementariesFollowContentInsets set to false and header has extendsBoundary set to true. Any ideas why it is happening? I can post code but for now I did't because it's very long. Thanks!

Witek Bobrowski
  • 3,749
  • 1
  • 20
  • 34
MWloczko
  • 135
  • 2
  • 8

1 Answers1

7

According to the documentation it looks like it's not possible to do if you are using estimated when creating the layout size.

The value of this property is ignored for any axis that uses an estimated value for its dimension. For more information, see estimated(_:).

When you are creating CompositionalLayout instance you can pass the config with the spacing between the sections:

let config = UICollectionViewCompositionalLayoutConfiguration()
config.interSectionSpacing = 50

return UICollectionViewCompositionalLayout(
    sectionProvider: { ... },
    configuration: config
)
mikro098
  • 2,173
  • 2
  • 32
  • 48
  • 1
    Is it possible to counter this `.estimated` behavior without setting a discrete section spacing value? Some layouts would only want spacing at the bottom of the list and not have that spacing applied to every section. – Alex Persian Aug 01 '22 at 19:19