Hi use FSCalender
in my application.
I take two buttons previous and next with those button actions I want customise.
Calendar don't allow expired Days.
I write following code it will working fine but when I am trying to wrong attempts in previous button on the same number of attempts not working on next button also.
@IBOutlet weak var calendarView: FSCalendar!
private var currentPage: Date?
private lazy var today: Date = {
return Date()
}()
private func moveCurrentPage(moveUp: Bool) {
let calendar = Calendar.current
var dateComponents = DateComponents()
dateComponents.month = moveUp ? 1 : -1
self.currentPage = calendar.date(byAdding: dateComponents, to: self.currentPage ?? self.today)
calenderView.setCurrentPage(self.currentPage!, animated: true)
}
I use that common method in both cases.
@IBAction func calender_BackkBtn(_ sender: Any) {
self.moveCurrentPage(moveUp: false)
}
@IBAction func calender_ForwardBtn(_ sender: Any) {
self.moveCurrentPage(moveUp: true)
}