Fscalendar: How to Change FSCalendar Appearance properties from AppDelegate?

Created on 16 Mar 2018  路  1Comment  路  Source: WenchaoD/FSCalendar

There's multiple FSCalendar in Multiple ViewContoller and I was to change color font and other thing for every FSCalendar.

so I write below code in each and every controller where I used FSCalendar which is not proper.

self.calendarVW.appearance.caseOptions = [.headerUsesUpperCase,.weekdayUsesSingleUpperCase]

self.calendarVW.appearance.headerTitleFont      = UIFont.init(name: Fonts.BalloRegular, size: 18)
self.calendarVW.appearance.weekdayFont          = UIFont.init(name: Fonts.RalewayRegular, size: 16)
self.calendarVW.appearance.titleFont            = UIFont.init(name: Fonts.RalewayRegular, size: 16)

self.calendarVW.appearance.headerTitleColor     = Colors.NavTitleColor
self.calendarVW.appearance.weekdayTextColor     = Colors.topTabBarSelectedColor
self.calendarVW.appearance.eventDefaultColor    = Colors.NavTitleColor
self.calendarVW.appearance.selectionColor       = Colors.purpleColor
self.calendarVW.appearance.titleSelectionColor  = Colors.NavTitleColor
self.calendarVW.appearance.todayColor           = Colors.purpleColor
self.calendarVW.appearance.todaySelectionColor  = Colors.purpleColor

self.calendarVW.appearance.headerMinimumDissolvedAlpha = 0.0 // Hide Left Right Month Name

so is there any way that I can define these properties in AppDelegate so I don't need to write in every controller.
Thanks in advance.

Most helpful comment

Create extension and function to configure appearance. Now, call that method in FSCalendar instance.

extension FSCalendar {
    func customizeCalenderAppearance() {
        self.appearance.caseOptions = [.headerUsesUpperCase,.weekdayUsesSingleUpperCase]

        self.appearance.headerTitleFont      = UIFont.init(name: Fonts.BalloRegular, size: 18)
        self.appearance.weekdayFont          = UIFont.init(name: Fonts.RalewayRegular, size: 16)
        self.appearance.titleFont            = UIFont.init(name: Fonts.RalewayRegular, size: 16)

        self.appearance.headerTitleColor     = Colors.NavTitleColor
        self.appearance.weekdayTextColor     = Colors.topTabBarSelectedColor
        self.appearance.eventDefaultColor    = Colors.NavTitleColor
        self.appearance.selectionColor       = Colors.purpleColor
        self.appearance.titleSelectionColor  = Colors.NavTitleColor
        self.appearance.todayColor           = Colors.purpleColor
        self.appearance.todaySelectionColor  = Colors.purpleColor

        self.appearance.headerMinimumDissolvedAlpha = 0.0 // Hide Left Right Month Name
    }
}



calendar.customizeCalendarAppearance()


>All comments

Create extension and function to configure appearance. Now, call that method in FSCalendar instance.

extension FSCalendar {
    func customizeCalenderAppearance() {
        self.appearance.caseOptions = [.headerUsesUpperCase,.weekdayUsesSingleUpperCase]

        self.appearance.headerTitleFont      = UIFont.init(name: Fonts.BalloRegular, size: 18)
        self.appearance.weekdayFont          = UIFont.init(name: Fonts.RalewayRegular, size: 16)
        self.appearance.titleFont            = UIFont.init(name: Fonts.RalewayRegular, size: 16)

        self.appearance.headerTitleColor     = Colors.NavTitleColor
        self.appearance.weekdayTextColor     = Colors.topTabBarSelectedColor
        self.appearance.eventDefaultColor    = Colors.NavTitleColor
        self.appearance.selectionColor       = Colors.purpleColor
        self.appearance.titleSelectionColor  = Colors.NavTitleColor
        self.appearance.todayColor           = Colors.purpleColor
        self.appearance.todaySelectionColor  = Colors.purpleColor

        self.appearance.headerMinimumDissolvedAlpha = 0.0 // Hide Left Right Month Name
    }
}



calendar.customizeCalendarAppearance()


Was this page helpful?
0 / 5 - 0 ratings