iosswiftxcodefscalendar

How to make event marked as big colour circle in FSCalendar?


I'm using FSCalendar in my app and I would like to add some events to my calendar by instead of small dots (the default way for marking event) I would like to mark the day with an event as big colour circle (the same way as e.g. the current day is marked in FSCalendar).

So basically my question is : How can I change background colour of any given day ?

Below you can see I picture which I found on https://github.com/WenchaoD/FSCalendar You can see many colours on the calendar so I assume it is possible to mark the day as I want but also I couldn't find right property or function to provide this output.

big colour circle on calendar

thanks for your time and help !


Solution

  • Try to add the following:

    1. Add a delegate FSCalendarDelegateAppearance

    2. Use method fillDefaultColorFor

      func calendar(_ calendar: FSCalendar, appearance: FSCalendarAppearance, fillDefaultColorFor date: Date) -> UIColor? {
      
       //format date according your need
      
       let calendarDateString = date.stringFromLocal(Format: "MM/dd/yyyy") 
      
       //your events date array
      
       if dateOfEvents.contains(calendarDateString) {
      
           return UIColor.blue
      
       }
      
       return nil //add your color for default 
      
      }