我在下面的项目中使用DSLCalendarView是链接:
https://github.com/PeteC/DSLCalendarView
我想设置在日历启动时选择的当前日期。
谢谢
答案 0 :(得分:0)
文件> DSLCalendarDayView.m
if (self.selectionState == DSLCalendarDayViewNotSelected) {
NSUInteger flags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit;
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *components = [calendar components:flags fromDate:[self.day date]];
NSDateComponents *componentsOfToday = [calendar components:flags fromDate:[NSDate date]];
NSDate *date = [calendar dateFromComponents:components];
NSDate *dateToday = [calendar dateFromComponents:componentsOfToday];
if (self.isInCurrentMonth) {
if ([date isEqualToDate:dateToday]) {
[[UIColor colorWithRed:(240/255.0) green:(240/255.0) blue:(239/255.0) alpha:1] setFill];
UIRectFill(self.bounds);
[[[UIImage imageNamed:@"DSLCalendarToday"] resizableImageWithCapInsets:UIEdgeInsetsMake(20, 20, 20, 20)] drawInRect:tmpBounds];
}
else
{
[[UIColor colorWithRed:(240/255.0) green:(240/255.0) blue:(239/255.0) alpha:1] setFill];
UIRectFill(self.bounds);
}
}
else {
if ([date isEqualToDate:dateToday]) {
[[UIColor colorWithRed:(212/255.0) green:(212/255.0) blue:(212/255.0) alpha:1] setFill]; //even if it is not current month, current day is colored
} else {
[[UIColor colorWithRed:(228/255.0) green:(228/255.0) blue:(227/255.0) alpha:1] setFill];
}
UIRectFill(self.bounds);
}
}其他......