IOS 拾遗

MDCalendar 一个简单的日历demo

2018-11-01  本文已影响4人  madaoCN

MDCalendar

a simple calendar demo as following

calendar.gif

using collectionview to realize the calendar

    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: String.init(describing: MADCalendarCell.self), for: indexPath) as! MADCalendarCell
        
        if indexPath.row < self.weekTitles.count {
            cell.titleLabel.text = self.weekTitles[indexPath.row]
        }else {
            let index = indexPath.row - self.weekTitles.count
            if index < self.currentMonthData.dayArr.count {                
                cell.model = self.currentMonthData.dayArr[index]
            }
        }
        return cell
    }

it is too simple,so i have no more thing to be written.

github demo

上一篇下一篇

猜你喜欢

热点阅读