ALCalendarPicker - iOS下的简洁简单的日历选择器

ALCalendarPicker这个框架是我在工作期间帮同事封装的一个框架.

使用示例

安装 - CocoaPods

pod "ALCalendarPicker"

特性

  1. 可配置当前日期背景颜色,文字,背景圆角度数
  2. 可配置特殊高亮日期(如预约日期),并且可以配置高亮日期背景颜色,文字,背景圆角度数
  3. 点击日期代理回调
  4. 支持设定起始日期

使用

    CGSize screenSize = [UIScreen mainScreen].bounds.size;
    // 宽度建议使用屏幕宽度 高度太低会有滚动条
    ALCalendarPicker *calP = [[ALCalendarPicker alloc] initWithFrame:CGRectMake(0, 64, screenSize.width, 400)];
    calP.delegate = self;
    // 起始日期 
//    calP.beginYearMonth = @"2017-01";
    calP.hightLightItems = @[@"2017-06-17",@"2017-05-22",@"2017-06-12"];
    calP.hightlightPriority = NO;
    
    // 高亮日期样式
    [calP setupHightLightItemStyle:^(UIColor *__autoreleasing *backgroundColor, NSNumber *__autoreleasing *backgroundCornerRadius, UIColor *__autoreleasing *titleColor) {
        *backgroundColor = [UIColor colorWithRed:234.0/255.0 green:240.0/255.0 blue:243.0/255.0 alpha:1];
        *backgroundCornerRadius = @(5.0);
        *titleColor = [UIColor colorWithRed:44.0/255.0 green:49.0/255.0 blue:53.0/255.0 alpha:1];
    }];
    
    // 今天日期样式
    [calP setupTodayItemStyle:^(UIColor *__autoreleasing *backgroundColor, NSNumber *__autoreleasing *backgroundCornerRadius, UIColor *__autoreleasing *titleColor) {
        *backgroundColor = [UIColor colorWithRed:78.0/255.0 green:133.0/255.0 blue:222.0/255.0 alpha:1];
        *backgroundCornerRadius = @(screenSize.width / 20); // 因为宽度是屏幕宽度,宽度 / 10 是cell 宽高 , cell宽高 / 2 为圆形
        *titleColor = [UIColor whiteColor];
    }];
    
    [self.view addSubview:calP];

使用代理以响应点击事件

- (void)calendarPicker:(ALCalendarPicker *)picker didSelectItem:(ALCalendarDate *)date date:(NSDate *)dateObj dateString:(NSString *)dateStr;

结尾

如果各位大佬有什么吐槽或者建议请在下方留言, 本人入坑iOS一年左右,有些代码写得不够成熟,还请各位多多指教.

另外大家可以关注下我写的另外一个封装AFNetworking的网络层框架ALNetworking

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 173,020评论 25 708
  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 12,198评论 4 61
  • 阳光森林~林海峰老师授课 每日十亿精选活性乳酸菌,更添加益生元果寡糖和植物浓缩素——营养加倍,健康加倍---记住乳...
    学趣多阅读 760评论 0 2
  • 想要向GitHub推送: 由于本地Git仓库和GitHub仓库之间的传输是通过SSH加密的,所以,需要一点设置: ...
    YT_Zou阅读 231评论 0 0
  • 昨天(2017.7.30.),我们同学一行34人,早晨六点半我们这支队伍兴高采烈的进军清原红河谷漂流。 红河谷位于...
    老王家大丫头阅读 343评论 0 0