How do I change colors of Sunday's to red and disable them . Actually I did not found any solution for this . Specially changing date color of only Sunday not the weekends.
Asked
Active
Viewed 1,322 times
1 Answers
0
If I am not wrong, FSCalendar is developed in Objective-C and can be used in Swift application using bridging headers. So to use it, efficiently in Swift based iOS application, I recommend creating a manager class .h and .m file and then using the manager class in Swift application. This will help you keep all your delegates of FSCalendar including its properties in the manager class itself.
Implement the below delegate method to change the color of the particular date:
-(UIColor *)calendar:(FSCalendar *)calendar appearance:(FSCalendarAppearance *)appearance titleDefaultColorForDate:(NSDate *)date
{
NSInteger day = [[[NSCalendar currentCalendar] components: NSCalendarUnitWeekday fromDate: curDate] weekday];
if(day == 1) //Sunday
{
return [UIColor redColor];
}
return [UIColor blackColor]; //Considering default date color is black
}
For disabling selection, please use below delegate method
-(BOOL)calendar:(FSCalendar *)calendar shouldSelectDate:(nonnull NSDate *)date atMonthPosition:(FSCalendarMonthPosition)monthPosition
{
NSInteger day = [[[NSCalendar currentCalendar] components: NSCalendarUnitWeekday fromDate: curDate] weekday];
if(day == 1) //Sunday
{
return NO;
}
return YES;
}
This is very basic code to give you idea and direction in which you may want to move forward to achieve the customization you want.

Parth Bhatt
- 19,381
- 28
- 133
- 216
-
Thank you . Can't we do it with swift language . I am new iOS . – Supreet Patil May 15 '20 at 07:11
-
No, as far as I know the delegates are not getting ported to Swift. – Parth Bhatt May 15 '20 at 14:27
-
Its added, implement FSCalendarDelegateAppearance protocol to the class. Then you can add titleDefaultColorFor delegate method. – Jitendra Tanwar May 15 '20 at 15:28
-
If I display the day variable I am getting only Sunday value i.e 1 . that makes the entire calendar red. But I want only Sunday's to be red – Supreet Patil May 23 '20 at 05:44