I’m trying to set different color for each day on the UICalendarView but, when I change one color it affect the color of all days.
I’m tried change the color using
Testing
func calendarView(_ calendarView: UICalendarView, decorationFor dateComponents: DateComponents) -> UICalendarView.Decoration? {
if let day = dateComponents.day {
if day == dates[0].day {
return .default(color: .red)
} else if day == dates[1].day {
return .default(color: .green)
} else if day == dates[2].day {
return .default(color: .blue)
}
}
}
But did not work correctly
The expected result would be this
enter image description here
New contributor
Thiago Martins is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.