WenchaoD / FSCalendar

A fully customizable iOS calendar library, compatible with Objective-C and Swift
MIT License
10.59k stars 1.93k forks source link

in swift example i created two buttons: week, month with corresponding actions. #1348

Open iOSayedAhmed opened 2 years ago

iOSayedAhmed commented 2 years ago
@IBAction func monthView(sender: UIButton) {
    self.calendar.setScope(.Month, animated: true)
}

@IBAction func weekView(sender: UIButton) {
    self.calendar.setScope(.Week, animated: true)
}
justdan0227 commented 2 years ago

I know you asked this quite a while ago, but I just did this and it appears to work just fine.

Remember to add func calendar(_ calendar: FSCalendar, boundingRectWillChange bounds: CGRect, animated: Bool) { self.calendarHeightConstraint.constant = bounds.height self.view.layoutIfNeeded() } and that your ViewController conforms to :

class ViewController: UIViewController,FSCalendarDataSource, FSCalendarDelegate

and that you have a

@IBOutlet weak var calendarHeightConstraint: NSLayoutConstraint!

set to the height constraint from the storyboard.