0

I use FSCalendar.

How i can allocate weekend day? For example in red color is weekend, other days except weekends is blue. I means to allocate not day of the week (like a sunday, saturday), namely day, i.e. date:

Monday is 0 - blue color

Tuesday is 1 - blue color

...

Saturday is 5 - red color

Sunday is 6 - red color

Monday is 7 - blue color

...

Saturday is 12 - red color

Sunday is 13 - red color

and so on

2 Answers2

1

Do the weekend / weekday calculation in your willDisplayCell method using this extension method for Date:

extension Date {
  var isWeekend: Bool {
    return NSCalendar(calendarIdentifier: NSCalendar.Identifier.gregorian)!.isDateInWeekend(self)
  }
}

Depending on whether it is weekend or weekday, set your FSCalendarCell's following properties:

cell?.eventIndicator.numberOfEvents = 1
cell?.eventIndicator.isHidden = false
cell?.eventIndicator.color = isWeekend ? UIColor.red : UIColor.blue
badhanganesh
  • 3,427
  • 3
  • 18
  • 39
0

i found solution for display weekday name in two character. And also you can change color of weekday label i mentioned below please check.

let weekdayEnumerator = calender.calendarWeekdayView.weekdayLabels
weekdayEnumerator.forEach { (cell) in
let c = cell
let str = c.text ?? " "
c.textColor = UIColor.red
c.text = String(str.dropLast())
}
sachin
  • 11
  • 1