FSCalendar events in Swift 3

1.1k views Asked by At

How can events be added to an FSCalendar in swift 3?

2

There are 2 answers

0
Mundi On

Implement the appropriate methods in a class adopting FSCalendarDataSource.

0
Joseph Mikko Manoza On
var datesWithEvent = ["2015-10-03", "2015-10-06", "2015-10-12", "2015-10-25"]
var datesWithMultipleEvents = ["2015-10-08", "2015-10-16", "2015-10-20", "2015-10-28"]

fileprivate lazy var dateFormatter2: DateFormatter = {
    let formatter = DateFormatter()
    formatter.dateFormat = "yyyy-MM-dd"
    return formatter
}()

func calendar(_ calendar: FSCalendar, numberOfEventsFor date: Date) -> Int {
    let dateString = self.dateFormatter2.string(from: date)
    if self.datesWithEvent.contains(dateString) {
        return 1
    }
    if self.datesWithMultipleEvents.contains(dateString) {
        return 3
    }
    return 0
}

Based On FsCalendar Documentation