FSCalendar:从头开始查看标题?
Posted
技术标签:
【中文标题】FSCalendar:从头开始查看标题?【英文标题】:FSCalendar: Header View from scratch? 【发布时间】:2021-08-13 18:34:36 【问题描述】:任何帮助将不胜感激。在过去的一周里,我一直在搜索我能找到的所有内容,以便为日历制作自定义标题视图。 Basic 实际上只是一个带有年份字幕的非常大的字体。
日历配置
extension FSCalendar
func customizeCalendar()
appearance.caseOptions = [.headerUsesUpperCase]
appearance.headerDateFormat = "MMM"
headerHeight = 0
var header: FSCalendarHeaderView!
header = CustomCalendarHeader()
header.configureAppearance()
appearance.headerTitleFont = UIFont.init(name: "SFProDisplay-Bold", size: 80)
appearance.headerTitleColor = COLOR_BLACK
appearance.headerTitleOffset = CGPoint(x: 0, y: 0)
appearance.headerMinimumDissolvedAlpha = 0.6
appearance.todayColor = COLOR_PRIMARY
appearance.todaySelectionColor = COLOR_BLACK
appearance.titleFont = UIFont(name: "SFProDisplay-Bold", size: 11)
appearance.titleSelectionColor = COLOR_BLACK
appearance.weekdayFont = UIFont(name: "SFProText-Semibold", size: 11)
appearance.weekdayTextColor = COLOR_GREY
appearance.eventDefaultColor = COLOR_BLACK
appearance.subtitleFont = UIFont(name: "SFProDisplay-Bold", size: 20)
appearance.selectionColor = COLOR_BLACK
尝试标题视图
class CustomCalendarHeader: FSCalendarHeaderView
var label: CustomUILabel =
let label = CustomUILabel(title: "Header")
label.font = UIFont.init(name: "SFProDisplay-Bold", size: 60)
return label
()
【问题讨论】:
【参考方案1】:您正在尝试子类化不应被子类化的类。从FSCalendarHeaderView
复制代码以制作您自己的 HeaderView。然后在FSCalendar.customizeCalendar()
中,将var header: FSCalendarHeaderView!
替换为var header: MyCustomHeader
。在您的自定义标头中,执行您想要的所有设置,删除您不想要的子视图等,但请确保所有变量名称保持相同以避免 FSCalendar 框架中的冲突。
【讨论】:
好的,所以我尝试返回并这样做,以便能够使用内置的委托方法更新月份。但是我意识到豆荚在 Obj-C 中?那么如何制作自定义子类?可以发个例子吗以上是关于FSCalendar:从头开始查看标题?的主要内容,如果未能解决你的问题,请参考以下文章