Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. extension ViewController: UICollectionViewDataSource {
  2. // ....
  3. func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
  4. let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MarksCollectionViewCell.identifier, for: indexPath) as! MarksCollectionViewCell
  5. let userMarks = students[indexPath.section].marks[subject(atColumn: indexPath.item)] ?? 0
  6. cell.setupCell(userMarks: userMarks, outOf: Consts.maximumAllotedMarks)
  7. return cell
  8. }
  9. func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
  10. let headerViewType: HeaderSupplementaryViewProtocol.Type
  11. let title: String
  12. if kind == RowHeaderSupplementaryView.identifier {
  13. headerViewType = RowHeaderSupplementaryView.self
  14. title = students[indexPath.section].name
  15. } else if kind == ColumnHeaderSupplementaryView.identifier {
  16. headerViewType = ColumnHeaderSupplementaryView.self
  17. title = subject(atColumn: indexPath.item).title
  18. } else {
  19. return UICollectionReusableView()
  20. }
  21. let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: headerViewType.identifier, withReuseIdentifier: headerViewType.reuseIdentifier, for: indexPath) as! HeaderSupplementaryView
  22. headerView.setTitle(title)
  23. return headerView
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement