美文网首页iOS Developer
ALCalendarPicker - iOS下的简洁简单的日历选

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

作者: Arclin | 来源:发表于2017-06-19 14:56 被阅读110次

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

相关文章

网友评论

    本文标题:ALCalendarPicker - iOS下的简洁简单的日历选

    本文链接:https://www.haomeiwen.com/subject/kkwgqxtx.html