mmick66 / CalendarView

An Easy to Use Calendar for iOS (Swift 5.0)
MIT License
598 stars 115 forks source link

negative or zero item sizes are not supported in the flow layout #128

Open 429329513wanting opened 4 years ago

429329513wanting commented 4 years ago

xcode:11.5 swift:5

    self.calendarView = CalendarView()
    self.calendarView?.frame = CGRect(x: 0, y: HT_StatusBarAndNavigationBarHeight, width: KScreenWidth, height: 200)
    calendarView?.dataSource = self
    calendarView?.delegate =  self
    calendarView?.marksWeekends = true
    calendarView?.direction = .horizontal
    calendarView?.setDisplayDate(Date())
    view.addSubview(self.calendarView!)
429329513wanting commented 4 years ago

//MARK: - calendarDelegate func startDate() -> Date {

    var dateComponents = DateComponents()
    dateComponents.month = -1

    let today = Date()

    let threeMonthsAgo = self.calendarView?.calendar.date(byAdding: dateComponents, to: today)!

    return threeMonthsAgo!
}
func endDate() -> Date {

  var dateComponents = DateComponents()

  dateComponents.month = 12
  let today = Date()

  let twoYearsFromNow = self.calendarView?.calendar.date(byAdding: dateComponents, to: today)!

    return twoYearsFromNow!
}

func calendar(_ calendar: CalendarView, didScrollToMonth date: Date) {

}

func calendar(_ calendar: CalendarView, didDeselectDate date: Date) {

}

func headerString(_ date: Date) -> String? {

    return "标题"
}

func calendar(_ calendar: CalendarView, didSelectDate date: Date, withEvents events: [CalendarEvent]) {

}

func calendar(_ calendar: CalendarView, canSelectDate date: Date) -> Bool {

    return false
}

func calendar(_ calendar: CalendarView, didLongPressDate date: Date, withEvents events: [CalendarEvent]?) {

}