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
}
我想在这里获取月份名称以在页眉中显示,以便月份名称可以随日历垂直滚动。我该怎么办? 谢谢您的帮助
答案 0 :(得分:0)
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
}
希望您已找到解决问题的方法。谢谢