iOS 开发-PDTSimpleCalendar日历展示

项目中的需求是需要用小红点来表明某一天有安排的,如下图:

Simulator Screen Shot 2017年1月12日 17.55.32.png

考虑到各位现在可能还没有相关接口数据,所以先展示部分功能,效果图如下:


Simulator Screen Shot 2017年1月12日 17.48.49.png

1.赶时间的朋友看过来:一段代码,一个第三方包,直接放到你们的工程,给你们上图的效果。
在你需要推出这个日程的界面复制下面的代码:注意修改报错的地方

PDTSimpleCalendarViewController *calenarViewController = [[PDTSimpleCalendarViewController alloc] init];
    [calenarViewController setEdgesForExtendedLayout:UIRectEdgeNone];
    calenarViewController.weekdayHeaderEnabled = YES;
    //    calenarViewController.delegate = self;
    calenarViewController.navigationItem.title = @"今日";
    NSDateComponents *dateComponents = [NSDateComponents new];
    dateComponents.month = -11;
    NSCalendar *calendar = [NSCalendar currentCalendar];
    calenarViewController.firstDate = [calendar dateByAddingComponents:dateComponents toDate:[NSDate date] options:0];
    dateComponents.month = 11;
    calenarViewController.lastDate = [calendar dateByAddingComponents:dateComponents toDate:[NSDate date] options:0];
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [calenarViewController scrollToDate:[NSDate date] animated:NO];
    });
    
    [[PDTSimpleCalendarViewCell appearance] setCircleTodayColor:[UIColor colorWithRed:0x2B/ 255.0 green:0x9A/255.0f blue:0x94/255.0f alpha:1]];
    [[DrawerViewController shareDrawer] pushToTargetController:calenarViewController];

修改过后的PDTSimpleCalendar代码链接:
https://pan.baidu.com/s/1slevK8d

2.下面我简要的说明一下我修改的地方

修改的大致概括:
a.先增一个类PDTSMyUILable,展示红点
b.修改PDTSimpleCalendarViewController类,主要是获取节假日信息,在- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath方法中判断是否有任务,并把节假日信息传给没一个cell;
c.修改PDTSimpleCalendarViewCell根据节假日信息进行展示,主要修改了- (void)setDate:(NSDate *)date calendar:(NSCalendar *)calendar方法
节假日信息API来源:http://apistore.baidu.com/apiworks/servicedetail/1116.html(免费)
搜索改动的地方,请全局搜索 modify by zcj
建议使用Xcode自带的文件对比工具FileMerge进行对比比较。

filemerge.png

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容