Reputation: 1
Hi I am new to iOS and was working to create a calendar using FSCalendar which is pretty awesome but I am unable to change the selection color of the range of dates in between the first selected date and last selected date. They are all of same colors. I want to display a lighter tone in between the two dates. For Example: Apart from 2nd Dec and 5th Dec in the screenshot screenshot, all the dates should be a different color.
How do I change the color of the dates inside the range excluding the final and initial dates?
Upvotes: 0
Views: 2371
Reputation: 20274
By using FSCalendarDelegateAppearance
you can control the selection fill color for individual dates.
Step 1. Ensure you have set the delegate:
yourFSCalendarObject.delegate = self
Step 2. Implement available FSCalendarDelegateAppearance
delegate methods:
In your case: calendar(_:appearance:fillSelectionColorFor:)
Example:
extension YourClassName: FSCalendarDelegateAppearance {
func calendar(_ calendar: FSCalendar, appearance: FSCalendarAppearance, fillSelectionColorFor date: Date) -> UIColor? {
//where startDate and endDate make the range of dates
if date >= startDate, date <= endDate {
return .yellow
} else {
return nil
}
}
}
Upvotes: 2