I have issue while using FSCalendar
I created FSCalendar with .week
Scope and there's unintended space at bottom of calendar.:
If I try to reduce calendar's height, its font size is also reducing and calendar looks squished.:
class ViewController: UIViewController {
fileprivate weak var calendar: FSCalendar!
override func viewDidLoad() {
super.viewDidLoad()
let calendar = FSCalendar(frame: CGRect(x: 0, y: 100, width: self.view.frame.width, height: 300))
self.calendar = calendar
view.addSubview(calendar)
calendar.locale = Locale(identifier: "en_US")
calendar.backgroundColor = .lightGray
calendar.scope = .week
calendar.headerHeight = 0
}
}
I have 3 big questions.
- Is there any way to remove that bottom space and fit view to calendar?
- Is FSCalendar's height should be
300
? - Can I use FSCalendar with AutoLayout Constraint?
CodePudding user response:
You need to update FSCalendar's frame. It doesn't update its frame by itself when you change the scope of the calendar. You can use the following method to update its frame using a manual layout(Already mentioned on the library's GitHub page):
func calendar(_ calendar: FSCalendar?, boundingRectWillChange bounds: CGRect, animated: Bool) {
calendar?.frame = CGRect(origin: calendar?.frame.origin ?? CGPoint.zero, size: bounds.size)
// Do other updates here
}
You can also do it with AutoLayout Constraint.