Skip to content

Instantly share code, notes, and snippets.

@yfujiki
Last active July 1, 2019 15:17
Show Gist options
  • Save yfujiki/90f308e0c636fdb7a94bd395412f4850 to your computer and use it in GitHub Desktop.
Save yfujiki/90f308e0c636fdb7a94bd395412f4850 to your computer and use it in GitHub Desktop.
func setupCatsSection() -> NSCollectionLayoutSection {
// 1. Configuring Section. Item -> Group -> Section
// Item
let item = NSCollectionLayoutItem(
layoutSize: NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0),
heightDimension: .fractionalHeight(1.0)))
item.contentInsets = NSDirectionalEdgeInsets(top: 6.7, leading: 10.0, bottom: 6.7, trailing: 10.0)
// Group
let group = NSCollectionLayoutGroup.vertical(
layoutSize: NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0),
heightDimension: .fractionalWidth(0.67)),
subitem: item,
count: 1)
// Section
let section = NSCollectionLayoutSection(group: group)
section.contentInsets = NSDirectionalEdgeInsets(top: 16.0,
leading: 0.0,
bottom: 16.0,
trailing: 0.0)
// 2. Header
section.boundarySupplementaryItems = [headerViewSupplementaryItem]
return section
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment