0
func calendar(_ calendar: JTAppleCalendarView, headerViewForDateRange range: (start: Date, end: Date), at indexPath: IndexPath) -> JTAppleCollectionReusableView {
        let header = calendar.dequeueReusableJTAppleSupplementaryView(withReuseIdentifier: "calendarHeader", for: indexPath) as!CalendarHeader
        header.monthLabel.text = monthName
        return header
    }

我想在这里获取月份名称以将其显示在 Header 中,以便月份名称可以随着日历垂直滚动。我应该如何得到它?感谢你们对我的帮助

4

1 回答 1

1
let currentCalendar = Calendar.current

var monthFormatter = DateFormatter()


func calendar(_ calendar: JTAppleCalendarView, 
headerViewForDateRange 
range: (start: Date, end: Date), 
at indexPath: IndexPath) -> JTAppleCollectionReusableView {


      let date = range.start
      let month = calendarCurrent.component(.month, from: date)
      var monthName = monthFormatter.monthSymbols[month - 1]
        let header = calendar.dequeueReusableJTAppleSupplementaryView(withReuseIdentifier: "calendarHeader", for: indexPath) as!CalendarHeader
        header.monthLabel.text = monthName
        return header

    }

希望您已经找到解决问题的方法。谢谢

于 2018-08-28T09:04:31.863 回答