Skip to content

Instantly share code, notes, and snippets.

@artur-ios-dev
Created March 25, 2020 16:20
Show Gist options
  • Save artur-ios-dev/34311311b4ccfd243fe6ccb4a77f6659 to your computer and use it in GitHub Desktop.
Save artur-ios-dev/34311311b4ccfd243fe6ccb4a77f6659 to your computer and use it in GitHub Desktop.
dataSource.supplementaryViewProvider = { collectionView, kind, indexPath -> UICollectionReusableView? in
    switch kind {
    case UICollectionView.elementKindSectionHeader:
        guard let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sampleHeaderIdentifier", for: indexPath) as? SampleCollectionReusableView else {
            fatalError("Header is not registered")
        }
        headerView.fill(with: "My Awesome Colours")
        return headerView
    default:
        fatalError("Element \(kind) not supported")
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment