CLWeeklyCalendarView 0.0.3

CLWeeklyCalendarView 0.0.3

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最后发布2016年3月

Enrico Susatyo维护。



CLWeeklyCalendarView是为iPhone设计的可滚动周历视图。它易于使用和定制。

alt tag

安装

如果您正在使用CocoaPods,您可以使用以下命令

pod 'CLWeeklyCalendarView'

手动

  • CLWeeklyCalendarViewSource文件夹拖到您的项目中。

初始化

在您的应用程序中使用CLWeeklyCalendarViewSource通常看起来像这样

//Initialize
-(CLWeeklyCalendarView *)calendarView
{
    if(!_calendarView){
        _calendarView = [[CLWeeklyCalendarView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 100)];
        _calendarView.delegate = self;
    }
    return _calendarView;
}

//Add it into parentView
[self.view addSubview:self.calendarView];

委托

在周历上的日期被选中后,以下委托函数将被触发

//After getting data callback
-(void)dailyCalendarViewDidSelect:(NSDate *)date
{
    //You can do any logic after the view select the date
}

您可以使用以下委托函数委托来告诉周历滚动到指定的日期

- (void)redrawToDate: (NSDate *)dt;

UI自定义

**请注意,自定义方法是可选的,如果您不应用它,它将直接触发默认值。

以下自定义密钥是允许的

CLCalendarWeekStartDay;    //The Day of weekStart from 1 - 7 - Default: 1
CLCalendarDayTitleTextColor; //Day Title text color,  Mon, Tue, etc label text color
CLCalendarPastDayNumberTextColor;    //Day number text color for dates in the past
CLCalendarFutureDayNumberTextColor;  //Day number text color for dates in the future
CLCalendarCurrentDayNumberTextColor; //Day number text color for today
CLCalendarSelectedDayNumberTextColor;    //Day number text color for the selected day
CLCalendarSelectedCurrentDayNumberTextColor; //Day number text color when today is selected
CLCalendarCurrentDayNumberBackgroundColor;   //Day number background color for today when not selected
CLCalendarSelectedDayNumberBackgroundColor;  //Day number background color for selected day
CLCalendarSelectedCurrentDayNumberBackgroundColor;   //Day number background color when today is selected
CLCalendarSelectedDatePrintFormat;   //Selected Date print format,  - Default: @"EEE, d MMM yyyy"
CLCalendarSelectedDatePrintColor;    //Selected Date print text color -Default: [UIColor whiteColor]
CLCalendarSelectedDatePrintFontSize; //Selected Date print font size - Default : 13.f
CLCalendarBackgroundImageColor;      //BackgroundImage color - Default : see applyCustomDefaults.

您需要使用此方法应用您的自定义

self.calendarView.calendarAttributes = @{
       CLCalendarBackgroundImageColor : [UIColor lightBackgroundColor],

       //Unselected days in the past and future, colour of the text and background.
       CLCalendarPastDayNumberTextColor : [UIColor lightGrayColor],
       CLCalendarFutureDayNumberTextColor : [UIColor lightGrayColor],

       CLCalendarCurrentDayNumberTextColor : [UIColor lightGrayColor],
       CLCalendarCurrentDayNumberBackgroundColor : [UIColor clearColor],

       //Selected day (either today or non-today)
       CLCalendarSelectedDayNumberTextColor : [UIColor whiteColor],
       CLCalendarSelectedDayNumberBackgroundColor : [UIColor primaryColor],
       CLCalendarSelectedCurrentDayNumberTextColor : [UIColor whiteColor],
       CLCalendarSelectedCurrentDayNumberBackgroundColor : [UIColor primaryColor],

       //Day: e.g. Saturday, 1 Dec 2016
       CLCalendarDayTitleTextColor : [UIColor darkGrayColor],
       CLCalendarSelectedDatePrintColor : [UIColor darkGrayColor],
       };

禁用日期选择

如果您在CLWeeklyCalendarView上调用setEnabledDates:,那么它将使只有启用的日期在UI中可选中。这在您 only 有特定天数的内容要显示时很有用。

如果您使用此选项,请确保还会设置CLCalendarDisabledDayBackgroundColorCLCalendarDisabledDayTextColor,以指示用户某些日期不可选。