I am using FSCalendar in my application according to requirement I implemented everything but facing one problem. When I switch month using button then calendar scrolls to next or previous month but it showing 1 date as automatically selected which is not needed. First Image where I press on button.
Here its shows auto selected date.
@IBAction func nextMonth(_ sender: UIButton){
let t = calendar.currentPage.addingTimeInterval(24*60*60)
let components = globalCurrentCalendar.dateComponents([.year, .month, .day], from: t)
yearParam = String(components.year!)
monthParam = String(components.month!)
let mnth = components.month! + 1
monthParam = String(mnth)
let date = Calendar.current.date(byAdding: .calendar, value: 1, to: t)
monthScrollDate = date!
self.calendar.select(self.formater.date(from:ConstantFile.dateToStringTemp(date: date!))!)
}
You need to do below steps for next month.
CalendarView
currentPage.CalendarView
currentPage.CalendarView
currentPage by newly created date.For Next Month
let currentMonth = self.calendarVW.currentPage
let nextMonth: Date? = gregorian.date(byAdding: .month, value: 1, to: currentMonth, options: [])
self.calendarVW.setCurrentPage(nextMonth!, animated: true)
For Previous Month
let currentMonth = self.calendarVW.currentPage
let previousMonth: Date? = gregorian.date(byAdding: .month, value: -1, to: currentMonth, options: [])
self.calendarVW.setCurrentPage(previousMonth!, animated: true)