gpt4 book ai didi

ios - JTAppleCalendar iOS 在标题中获取月份以使用日历滚动它

转载 作者:行者123 更新时间:2023-11-28 23:50:33 24 4
gpt4 key购买 nike

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
}

我想在此处获取月份名称以将其显示在标题中,以便月份名称可以随日历垂直滚动。我应该怎么得到它?谢谢你帮助我

最佳答案

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

}

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

关于ios - JTAppleCalendar iOS 在标题中获取月份以使用日历滚动它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52053473/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com