Home > Software design >  FSCalendar Persian: How to change weekday order?
FSCalendar Persian: How to change weekday order?

Time:08-21

I'm using Objective-c in my project, and using FSCalendar Persian pod.

this is my code for showing calendar:

calendar = [[FSCalendar alloc] initWithFrame:CGRectMake(0, 0, _calendarContainer.frame.size.width, _calendarContainer.frame.size.height)];
calendar.locale = [NSLocale localeWithLocaleIdentifier:@"fa_IR"];
calendar.calendarIdentifier = NSCalendarIdentifierPersian;
calendar.firstWeekday = 1;
calendar.placeholderType = FSCalendarPlaceholderTypeNone;
calendar.dataSource = self;
calendar.delegate = self;

calendar.appearance.headerTitleColor = [UIColor primaryColor];
calendar.appearance.headerTitleFont = [UIFont fontWithName:NSLocalizedString(@"DefaultFontBold", @"") size:15];
calendar.appearance.weekdayTextColor = [UIColor primaryColor];

calendar.appearance.selectionColor = [UIColor clearColor];
calendar.appearance.borderSelectionColor = [UIColor primaryColor];
calendar.appearance.titleSelectionColor = [UIColor primaryColor];

calendar.appearance.titleDefaultColor = [UIColor primaryColor];

calendar.appearance.todayColor = [UIColor primaryColor];
calendar.appearance.titleTodayColor = [UIColor whiteColor];

calendar.appearance.titleFont = [UIFont fontWithName:NSLocalizedString(@"DefaultFont", @"") size:14];

calendar.appearance.titleWeekendColor = [UIColor redColor];
calendar.calendarWeekdayView.weekdayLabels[5].textColor = [UIColor redColor];

[_calendarContainer addSubview:calendar];

enter image description here

In my country the first week day is saturday(شنبه), and the last week day is Friday(جمعه).

my problem is I want first week day to be the first column from the right side not the left side and the last week day be the first column from the left side.

how can I fix this problem?

CodePudding user response:

I found what is the problem, the problem is in this line of code:

calendar.locale = [NSLocale localeWithLocaleIdentifier:@"fa_IR"];

I must change fa_IR to fa-IR (change underline to dash) and the problem solved.

  • Related