Skip to content

Instantly share code, notes, and snippets.

@michzio
Last active May 3, 2020 09:13
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 michzio/3ee49dbe297dd7fa2b175d83411f633c to your computer and use it in GitHub Desktop.
Save michzio/3ee49dbe297dd7fa2b175d83411f633c to your computer and use it in GitHub Desktop.
// MARK: - Setup
extension CollectionViewController {
private func configureCollectionView() {
view.addSubview(collectionView)
collectionView.register(HostingControllerCollectionViewCell<AnyView>.self, forCellWithReuseIdentifier: HostingControllerCollectionViewCell<AnyView>.reuseIdentifier)
collectionView.register(BadgeSupplementaryView.self, forSupplementaryViewOfKind: "badge", withReuseIdentifier: BadgeSupplementaryView.reuseIdentifier)
collectionView.register(EmptySupplementaryView.self, forSupplementaryViewOfKind: "badge", withReuseIdentifier: EmptySupplementaryView.reuseIdentifier)
supplementaryKinds.forEach { kind in
collectionView.register(HostingControllerCollectionReusableView<AnyView>.self, forSupplementaryViewOfKind: kind, withReuseIdentifier: HostingControllerCollectionReusableView<AnyView>.reuseIdentifier)
}
}
private func configureDataSource() {
dataSource = UICollectionViewDiffableDataSource<Section, Item>(collectionView: collectionView, cellProvider: cellProvider)
dataSource.supplementaryViewProvider = supplementaryViewProvider
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment