2017-01-07 91 views

回答

1

在採用FSCalendarDataSource的課堂上實施適當的方法。

0
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 
} 

基於FsCalendar文檔