Last active
July 1, 2019 15:17
-
-
Save yfujiki/90f308e0c636fdb7a94bd395412f4850 to your computer and use it in GitHub Desktop.
Cats section for https://github.com/yfujiki/CompositionalLayoutSample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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