0
我在iOS中使用JTCalender。我想用相同的颜色制作诸如日期,月份名称等标签的颜色。截至目前,它在某些日期是黑色的。自定义iOS中JTCalender的颜色?
请suggesst我怎样才能做到这一点?
我在iOS中使用JTCalender。我想用相同的颜色制作诸如日期,月份名称等标签的颜色。截至目前,它在某些日期是黑色的。自定义iOS中JTCalender的颜色?
请suggesst我怎样才能做到这一点?
您可以通过使用JTCalendar委托方法
- (UIView<JTCalendarDay> *)calendarBuildDayView:(JTCalendarManager *)calendar
{
JTCalendarDayView *view = [JTCalendarDayView new];
view.textLabel.font = [UIFont fontWithName:@"Avenir-Light" size:13];
view.textLabel.textColor = [UIColor blackColor];
return view;
}
- (void)calendar:(JTCalendarManager *)calendar prepareDayView:(JTCalendarDayView *)dayView
{
dayView.hidden = NO;
// Test if the dayView is from another month than the page
// Use only in month mode for indicate the day of the previous or next month
if([dayView isFromAnotherMonth]){
dayView.hidden = YES;
}
// Today
else if([_calendarManager.dateHelper date:[NSDate date] isTheSameDayThan:dayView.date]){
dayView.circleView.hidden = NO;
dayView.circleView.backgroundColor = [UIColor blueColor];
dayView.dotView.backgroundColor = [UIColor whiteColor];
dayView.textLabel.textColor = [UIColor whiteColor];
}
// Selected date
else if(_dateSelected && [_calendarManager.dateHelper date:_dateSelected isTheSameDayThan:dayView.date]){
dayView.circleView.hidden = NO;
dayView.circleView.backgroundColor = [UIColor redColor];
dayView.dotView.backgroundColor = [UIColor whiteColor];
dayView.textLabel.textColor = [UIColor whiteColor];
}
// Another day of the current month
else{
dayView.circleView.hidden = YES;
dayView.dotView.backgroundColor = [UIColor redColor];
dayView.textLabel.textColor = [UIColor blackColor];
}
// Your method to test if a date have an event for example
if([self haveEventForDay:dayView.date]){
dayView.dotView.hidden = NO;
}
else{
dayView.dotView.hidden = YES;
}
}
注定制天观点:该代码是在Objective C,请使用斯威夫特各自的方法。
来源:https://github.com/jonathantribouharet/JTCalendar
编辑:(正如Kglay Kophyo建议) 可以更改月份的颜色代表。
- (UIView *)calendarBuildMenuItemView:(JTCalendarManager *)calendar
{
UILabel *label = [UILabel new];
label.textColor = [UIColor redColor]; // your color return label;
}
如何更改月份的文本颜色? – Techiee
请建议从哪里可以更改月份的颜色 – Techiee
@deepakkumar - 你可以在代表中更改月份的颜色。 (UIView *)calendarBuildMenuItemView:(JTCalendarManager *)日历 { UILabel * label = [UILabel new]; label.textColor = [UIColor redColor]; //你的颜色 退货标签; } –