【发布时间】:2021-09-14 13:58:16
【问题描述】:
我已将 FSCalendar 范围模式设置为周。在该标题日期格式之后,我设置了calendar.appearance.headerDateFormat = "dd MMMM yyyy EEEE"
它显示正确的格式。
- 我面临的问题是它给出了一周的开始日期。如果我选择任何日期,如何更新 Header 的值。 我还没有找到它的任何属性或方法。
- 我的选择日期是 2021 年 9 月 13 日,但标题日期是 2021 年 9 月 16 日。
添加了代码和图片。
func setupFSCalendar() {
ViewCalendar.frame = CGRect(x: 0, y: 78, width: view.frame.width, height: 100)
ViewCalendar.backgroundColor = ("#455a64").toColor()
let calendar = FSCalendar(frame: CGRect(x: 0, y: 0, width: ViewCalendar.frame.width, height: 250))
calendar.layoutIfNeeded()
calendar.dataSource = self
calendar.delegate = self
calendar.appearance.weekdayTextColor = .white // week name color
calendar.appearance.headerDateFormat = "dd MMMM yyyy EEEE"
calendar.appearance.headerTitleColor = UIColor.white
calendar.appearance.headerTitleFont = UIFont.systemFont(ofSize: 12)
calendar.appearance.titleWeekendColor = UIColor.white
calendar.appearance.titleDefaultColor = .white
calendar.scrollDirection = .horizontal
calendar.appearance.weekdayFont = UIFont.systemFont(ofSize: 12)
calendar.appearance.titleFont = UIFont.systemFont(ofSize: 18)
calendar.appearance.titleTodayColor = ("#54a767").toColor()
calendar.appearance.selectionColor = ("#788f9b").toColor()
calendar.appearance.todayColor = nil
calendar.appearance.subtitleWeekendColor = UIColor.white
calendar.placeholderType = .none /// to remove last month dates
calendar.appearance.headerMinimumDissolvedAlpha = 0 // removes next prev month title.
calendar.backgroundColor = .clear
calendar.firstWeekday = 2
calendar.scope = .week
ViewCalendar.addSubview(calendar)
}
func calendar(_ calendar: FSCalendar, didSelect date: Date, at monthPosition: FSCalendarMonthPosition) {
print(date)
calendar.setCurrentPage(date, animated: true)
calendar.select(date)
}
【问题讨论】:
标签: ios swift calendar fscalendar