Closed kishikawakatsumi closed 5 years ago
Refer collection view size instead of content size in decoration views.
let section = NSCollectionLayoutSection(group: group) section.interGroupSpacing = 5 section.contentInsets = NSDirectionalEdgeInsets(top: 40, leading: 40, bottom: 40, trailing: 40) let sectionBackgroundDecoration = NSCollectionLayoutDecorationItem.background( elementKind: SectionDecorationViewController.sectionBackgroundDecorationElementKind) sectionBackgroundDecoration.contentInsets = NSDirectionalEdgeInsets(top: 10, leading: 5, bottom: 5, trailing: 10) section.decorationItems = [sectionBackgroundDecoration]
The above code should be rendered as the following;
Another example:
let section = NSCollectionLayoutSection(group: group) section.interGroupSpacing = 5 section.contentInsets = NSDirectionalEdgeInsets(top: 10, leading: 0, bottom: 5, trailing: 0) let sectionBackgroundDecoration = NSCollectionLayoutDecorationItem.background( elementKind: SectionDecorationViewController.sectionBackgroundDecorationElementKind) sectionBackgroundDecoration.contentInsets = NSDirectionalEdgeInsets(top: 10, leading: 5, bottom: 5, trailing: 10) section.decorationItems = [sectionBackgroundDecoration]
Refer collection view size instead of content size in decoration views.
The above code should be rendered as the following;
Another example: