Last active
July 10, 2019 23:47
-
-
Save yfujiki/8c29a0fbfe27650cc9f4da2b79599f1e to your computer and use it in GitHub Desktop.
CatFoods Section for https://github.com/yfujiki/CompositionalLayoutSample
This file contains hidden or 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 setupCatFoodsSection() -> NSCollectionLayoutSection { | |
// 1. Configuring Section Layout. Item -> Group -> Section | |
// Item | |
let item = NSCollectionLayoutItem( | |
layoutSize: NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), | |
heightDimension: .fractionalHeight(0.5))) | |
item.contentInsets = NSDirectionalEdgeInsets(top: 4.0, | |
leading: 0.0, | |
bottom: 4.0, | |
trailing: 0.0) | |
// Group | |
let group = NSCollectionLayoutGroup.vertical( | |
layoutSize: NSCollectionLayoutSize(widthDimension: .fractionalWidth(0.5), | |
heightDimension: .absolute(240)), | |
subitem: item, | |
count: 2) | |
// Section | |
let section = NSCollectionLayoutSection(group: group) | |
section.contentInsets = NSDirectionalEdgeInsets(top: 16.0, | |
leading: 0.0, | |
bottom: 16.0, | |
trailing: 0.0) | |
// 2. Horizontal Scroll | |
section.orthogonalScrollingBehavior = .groupPaging | |
// 3. Header | |
section.boundarySupplementaryItems = [headerViewSupplementaryItem] | |
return section | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment