iosswiftfscalendar

FSCalendar How To Understand If User Scrolled the Calendar Page


I hid the fscalendar header (previous, current and next date texts) and added two buttons (next and previous month) and label which shows month name of current fscalendar page. I'm trying to change month name label's text when user scrolled the page. I have min and max dates, I want to stop scrolling when user reaches those pages. How may I do that?

Thanks


Solution

  • calendarCurrentPageDidChange(yourfsCalender)
    

    To get Month Name

    func calendarCurrentPageDidChange(_ calendar: FSCalendar) {
        let currentPageDate = calendar.currentPage
        let month = Calendar.current.component(.month, from: currentPageDate)
        let monthName = DateFormatter().monthSymbols[month - 1].capitalized
        print(monthName)
        lblMonth.text = monthName   
    }