ZTCalendar
示例
要运行示例项目,请克隆仓库,然后首先从 Example 目录运行 pod install
。
要求
安装
ZTCalendar 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中
pod 'ZTCalendar'
创建横向日历
- (ZTCalendarView *)calendarView
{
if (_calendarView) {
return _calendarView;
}
_calendarView = [[ZTCalendarView alloc] initWithDefaultSelectPosition:ZTInfiniteDefaultSelectPositionRight];
_calendarView.calendarDelegate = self;
_calendarView.backgroundColor = [UIColor whiteColor];
return _calendarView;
}
实现代理方法
#pragma mark - ZTCalendarViewDelegate
- (CGFloat)widthOfCellInCalendarView:(ZTCalendarView *)calendarView
{
return 70;
}
- (ZTInfiniteCell *)calendarView:(ZTCalendarView *)calendarView cellAtDate:(NSDate *)date
{
ZTCalendarCell *cell = [[ZTCalendarCell alloc] init];
[cell configureWith:date];
return cell;
}
- (BOOL)shouldHilightDateShowing:(ZTCalendarView *)calendarView
{
return YES;
}
- (NSDate * _Nonnull )dateShowingOfCalendarView:(ZTCalendarView *)calendarView
{
return [NSDate date];
}
- (BOOL)calendarView:(ZTCalendarView *)calendarView shouldSelectCellAtDate:(NSDate *)date
{
return YES;
}
- (void)calendarView:(ZTCalendarView *)calendarView didSelectCellAtDate:(NSDate *)date
{
}
- (NSDate *)minDateOfCalendarView:(ZTCalendarView *)calendarView
{
return [NSDate dateWithTimeIntervalSinceNow:-10*24*60*60];
}
创建横向无限滚动视图
- (ZTInfiniteListView *)infiniteListView
{
if (_infiniteListView) {
return _infiniteListView;
}
_infiniteListView = [[ZTInfiniteListView alloc] init];
_infiniteListView.infiniteDelegate = self;
return _infiniteListView;
}
实现代理方法
#pragma mark - ZTInfiniteListViewDelegate
- (CGFloat)widthOfCellInInfiniteListView:(ZTInfiniteListView *)infiniteListView
{
return 70.0f;
}
- (ZTInfiniteCell *)infiniteListView:(ZTInfiniteListView *)infiniteListView cellAtIndex:(NSInteger)idx
{
ZTIndexCell *cell = [[ZTIndexCell alloc] init];
cell.label.text = [NSString stringWithFormat:@"%zd", idx];
return cell;
}
- (void)infiniteListView:(ZTInfiniteListView *)infiniteListView didSelectCellAtIndex:(NSInteger)idx
{
self.infiniteLabel.text = [NSString stringWithFormat:@"选中序号:%zd", idx];
}
- (NSNumber *)maxIndexOfInfiniteListView:(ZTInfiniteListView *)infiniteListView
{
return @10;
}
Author
授权
ZTCalendar 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。