Joseph Mikko Manoza
Joseph Mikko Manoza

Reputation: 296

How to Set ImagesForDates For Specific Dates (08-10-2017) In FsCalendar Using Swift

I Already Set Dates On This Method

private func calendar(_ calendar: FSCalendar, imageFor date: Date) -> UIImage? {

let day: Int! = self.gregorian.component(.day, from: date)
        return [1,2,3].contains(day) ? UIImage(named: "mens") : nil
 }

I would like to set it on this - It doesn't work please help me :)

func calendar(_ calendar: FSCalendar, imageFor date: Date) -> UIImage? {
    let day: Int! = self.gregorian.component(.day, from: date)
    return [08-10-2017, 08-11-2017].contains(day) ? UIImage(named: "mens") : nil
 }

Upvotes: 1

Views: 737

Answers (1)

Aditya Srivastava
Aditya Srivastava

Reputation: 2650

let day: Int! = self.gregorian.component(.day, from: date)

This line will return you the day. For example : - 08-10-2017 it will return 08. So, first convert the date func calendar(_ calendar: FSCalendar, imageFor date: Date) -> UIImage? into your dd-MM-yyyy format.

Then use this return [08-10-2017, 08-11-2017].contains(date) ? UIImage(named: "mens") : nil

Hope this helps!

Upvotes: 1

Related Questions