ZBJCalendar 是创建日历视图的一种简单方法。ZBJCalendar 的概念来源于 UICollectionView 或 UITableViewDataSource。
众所周知,UICollectionView 和 UITableViewDataSource 设定了单元格与索引路径之间的相应关系。不同之处在于,ZBJCalendar 设定了单元格与日期之间的相应关系,这是理解 ZBJCalendar 的关键。
pod 'ZBJCalendar'
这是 ZBJCalendar 的主要类,该类的实例是一个日历视图。
您可以找到一些熟悉的属性和新型属性
dataSource
是一个 <ZBJCalendarDataSource>
协议属性,用于自定义单元格或头部delegate
是一个 <ZBJCalendarDelegate>
协议属性,用于处理日单元格的显示和行为。firstDate
和 lastDate
用于设置日历的开始日期和结束日期。selectionMode
是一个 ZBJSelectionMode
枚举,表示单选、可编辑选或不可选。它还包含一些熟悉的成员方法,如
- (void)registerCellClass:(id)clazz withReuseIdentifier:(NSString *)identifier;
- (void)reloadData;
- (id)cellAtDate:(NSDate *)date;
- (void)reloadCellsAtDates:(NSSet<<NSDate *> *)dates;
这是一个用于自定义单元格数据模型对象的协议。它提供了有关外观和数据的单元格和辅助视图信息。
- (void)calendarView:(ZBJCalendarView *)calendarView configureCell:(id)cell forDate:(NSDate *)date;
- (void)calendarView:(ZBJCalendarView *)calendarView configureSectionHeaderView:(id)headerView firstDateOfMonth:(NSDate *)firstDateOfMonth;
- (void)calendarView:(ZBJCalendarView *)calendarView configureSectionFooterView:(id)headerView lastDateOfMonth:(NSDate *)lastDateOfMonth;
- (void)calendarView:(ZBJCalendarView *)calendarView configureWeekDayLabel:(UILabel *)dayLabel atWeekDay:(NSInteger)weekDay;
这是一个用于处理 ZBJCalendar 显示和行为的协议。
- (BOOL)calendarView:(ZBJCalendarView *)calendarView shouldSelectDate:(NSDate *)date;
- (void)calendarView:(ZBJCalendarView *)calendarView didSelectDate:(NSDate *)date ofCell:(id)cell;
ZBJCalendar 通过此类提供了一个周视图,您可以通过实现来更改其样式
这个分类为 NSDate
提供了实用方法。
本类别提供用于索引路径和日期之间对应关系的操作方法。
ZBJCalendar 在MIT许可证下发布。