Skip to content

Instantly share code, notes, and snippets.

@SebastianBoldt
Last active March 12, 2020 19:28
Show Gist options
  • Save SebastianBoldt/e36449101eff55ce58793c4479dc192a to your computer and use it in GitHub Desktop.
Save SebastianBoldt/e36449101eff55ce58793c4479dc192a to your computer and use it in GitHub Desktop.
class ViewController: UIViewController {
@IBOutlet var collectionview: UICollectionView!
lazy var dataSource = UICollectionViewDiffableDataSource<Section, Item>(collectionView: self.collectionview,
cellProvider: self.cellProvider)
lazy var cellProvider: (UICollectionView, IndexPath, Item) -> UICollectionViewCell? = { collectionView, indexPath, item in
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath)
cell.backgroundColor = item.color
return cell
}
override func viewDidLoad() {
super.viewDidLoad()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment