I'm trying the tutorial for JTAppleCalendar from the youtube. In this I'm making custom calendar in which under the date label I'm trying to show the current month name. I'm also getting the month name at the top of the view. When I pass the month name value it shows properly at the top of the view but when i pass to my label in a cell it just show label text not the month name. How can I get the month name there? My code for calendar is this:
func setUpViewForCalendar(from visibleDate: DateSegmentInfo){
let date = visibleDate.monthDates.first?.date
self.formatter.dateFormat = "yyyy MM dd"
self.yearLbl.text = self.formatter.string(from: date!)
self.formatter.dateFormat = "MMMM"
self.monthLbl.text = self.formatter.string(from: date!)
}
extension ViewController : JTAppleCalendarViewDataSource{
func calendar(_ calendar: JTAppleCalendarView, willDisplay cell: JTAppleCell, forItemAt date: Date, cellState: CellState, indexPath: IndexPath) {
}
func configureCalendar(_ calendar: JTAppleCalendarView) -> ConfigurationParameters {
formatter.dateFormat = "yyyy MM dd"
formatter.timeZone = Calendar.current.timeZone
formatter.locale = Calendar.current.locale
let startDate = formatter.date(from: "2018 01 01")
let endDate = formatter.date(from: "2018 12 31")
let parameter = ConfigurationParameters(startDate: startDate!, endDate: endDate!)
return parameter
}
}
extension ViewController : JTAppleCalendarViewDelegate{
func calendar(_ calendar: JTAppleCalendarView, cellForItemAt date: Date, cellState: CellState, indexPath: IndexPath) -> JTAppleCell {
let cell = calendar.dequeueReusableJTAppleCell(withReuseIdentifier: "customCell", for: indexPath) as! CustomCell
cell.dateLbl.text = cellState.text
cell.monthLbl.text = self.monthLbl.text
print(cell.monthLbl.text)
handleCellTextColor(view: cell, cellState: cellState)
return cell
}
func calendar(_ calendar: JTAppleCalendarView, didSelectDate date: Date, cell: JTAppleCell?, cellState: CellState) {
handleCellTextColor(view: cell!, cellState: cellState)
}
func calendar(_ calendar: JTAppleCalendarView, didDeselectDate date: Date, cell: JTAppleCell?, cellState: CellState) {
handleCellTextColor(view: cell!, cellState: cellState)
}
func calendar(_ calendar: JTAppleCalendarView, didScrollToDateSegmentWith visibleDates: DateSegmentInfo) {
setUpViewForCalendar(from: visibleDates)
}
}