0
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
    }

I want to get the month name here to display it in Header so that month name can scroll with the calendar vertically. How should I get it? Thank you for helping me

EstevaoLuis
  • 2,422
  • 7
  • 33
  • 40
G.Kumar
  • 128
  • 9

1 Answers1

1
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

    }

Hope you have found the solution to your problem. Thanks

EstevaoLuis
  • 2,422
  • 7
  • 33
  • 40
ayon.gupta
  • 178
  • 7