Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MonthCalendarCell: UICollectionViewCell {
- var dateLabel: UILabel?
- func addDateLabel(label: UILabel) {
- self.dateLabel = label
- self.addSubview(label)
- }
- }
- override init(frame: CGRect, collectionViewLayout layout: UICollectionViewLayout) {
- let calendarFlowLayout = CalendarFlowLayout()
- super.init(frame: frame, collectionViewLayout: calendarFlowLayout)
- self.dataSource = self
- self.delegate = self
- self.registerClass(MonthCalendarCell.self, forCellWithReuseIdentifier: self.identifier)
- // TODO: work on this
- self.backgroundColor = UIColor.groupTableViewBackgroundColor()
- }
- func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
- let cell = collectionView.dequeueReusableCellWithReuseIdentifier(self.identifier, forIndexPath: indexPath) as MonthCalendarCell
- let label = UILabel()
- label.text = "1"
- label.frame = CGRectMake(0, 0, cell.bounds.width, cell.bounds.height)
- label.textAlignment = NSTextAlignment.Center
- label.backgroundColor = UIColor.redColor()
- self.highlightView(label)
- cell.addDateLabel(label)
- return cell
- }
- func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
- let cell = collectionView.dequeueReusableCellWithReuseIdentifier(self.identifier, forIndexPath: indexPath) as MonthCalendarCell
- println(cell.dateLabel!)
- }
- class MonthCalendarCell: UICollectionViewCell {
- var dateLabel: UILabel? {
- get {
- return self.dateLabel
- }
- set(label) {
- self.addSubview(label!)
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement