Skip to content

Instantly share code, notes, and snippets.

@wdchris
Created May 18, 2020 17:26
Show Gist options
  • Save wdchris/04fae466c85f445818c52bccd0c27688 to your computer and use it in GitHub Desktop.
Save wdchris/04fae466c85f445818c52bccd0c27688 to your computer and use it in GitHub Desktop.
class CalendarCell: UICollectionViewCell {
@IBOutlet weak var dateLabel: UILabel!
static let identifier = "calendarCell"
static func register(with collectionView: UICollectionView) {
collectionView.register(UINib.init(nibName: "CalendarCell", bundle: nil), forCellWithReuseIdentifier: identifier)
}
static func dequeue(from collectionView: UICollectionView, at indexPath: IndexPath, forDay day: Int) -> CalendarCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: identifier, for: indexPath) as? CalendarCell ?? CalendarCell()
cell.dateLabel.text = String(format: "%02d", day)
return cell
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment