2016-12-05 6 views
0

私は、iOSでJTCalenderを使用しています。日付、月名などの色を同じ色にしたいと思っています。今のところ、いくつかの日付では黒です。iOSのJTCalenderで色をカスタマイズしますか?

enter image description here

どのように私はこれを達成することができますsuggesstしてください?

答えて

2

あなたは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; 
} 
+0

月の文字色を変更するにはどうすればよいですか? – Techiee

+0

私は月の色を変更することができますからお勧めします – Techiee

+0

@deepakkumar - 私は代理人の月の色を変更することができます。 - (UIView *)calendarBuildMenuItemView:(JTCalendarManager *)calendar { UILabel * label = [UILabel new]; label.textColor = [UIColor redColor]; //あなたの色 リターンラベル; } –

関連する問題