Skip to content

Instantly share code, notes, and snippets.

@tifoaudii
Created April 5, 2020 13:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tifoaudii/d7025a9c30ca2ab1432822bd30c6e619 to your computer and use it in GitHub Desktop.
Save tifoaudii/d7025a9c30ca2ab1432822bd30c6e619 to your computer and use it in GitHub Desktop.
//1
let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), heightDimension: .fractionalWidth(1.0))
let item = NSCollectionLayoutItem(layoutSize: itemSize)
//2
let groupSize = NSCollectionLayoutSize(widthDimension: .absolute(140), heightDimension: .absolute(220))
let group = NSCollectionLayoutGroup.vertical(layoutSize: groupSize, subitem: item, count: 1)
group.contentInsets = .init(top: 5, leading: 5, bottom: 5, trailing: 5)
//3
let headerSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), heightDimension: .estimated(44))
let sectionHeader = NSCollectionLayoutBoundarySupplementaryItem(layoutSize: headerSize, elementKind: MovieViewController.sectionHeaderElementKind, alignment: .top)
//4
let section = NSCollectionLayoutSection(group: group)
section.orthogonalScrollingBehavior = .groupPaging
section.boundarySupplementaryItems = [sectionHeader]
return section
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment