FSCalendar
FSCalendar copied to clipboard
Row height for weekly calendar.
How to change row height for weekly calendar? i.e. I am showing weekly calendar with height of 120 But it is showing very tiny dates under week days. how can make them bigger?
Screen Shot of my view.
@BurhanMughal try to play with Heigh Attributes in StoryBoard. I had the same problem and I started to change the library classes related with collection view flow layout, but if you don't have to make a big customisation this is the fastest way, it works for me. ¡I expect this will help you 😃!
I had the same problem till I figured out that FSCalendar is always calculating the row height for the monthly calendar. You need to look at FSCalendar.m
- (CGFloat)preferredRowHeight
:
if (!self.floatingMode) {
_preferredRowHeight = (contentHeight-padding*2)/6.0;
}
So you could either remove the /6.0
or set the calendar frame height to something like (finalHeight - headerHeight - weekdayHeight - 10) * 6 + headerHeight + weekdayHeight
I think the row height should be calculated differently if only the weekly calendar is shown. This would it make much easier.
@WenchaoD can you fix it? or accept PR?
Any plans to merge this in? Facing same problem with week view!
this is my one..I can select calendar dates in two colors
the same
I did some solution which is working in my case (I use only week scope): https://stackoverflow.com/questions/46069173/how-do-i-scale-the-height-of-fscalendar/73946074#73946074
Probably there is room for improvements regarding constant for height.
I tried this which worked:
- Add an IBOutlet for FSCalendar view height constraint and set its value to 280 on viewDidLoad()2.
@IBOutlet weak var calendarView: FSCalendar!
@IBOutlet weak var calendarViewHeight: NSLayoutConstraint!
override func viewDidLoad() {
super.viewDidLoad()
calendarView.delegate = self
calendarViewHeight.constant = 280
}
-
set FSCalendar view's scope property to week in ViewDidAppear()
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
calendarView.scope = .week
}
-
conform you viewController class to
FSCalendarDataSource
and add this code:func calendar(_ calendar: FSCalendar, boundingRectWillChange bounds: CGRect, animated: Bool) {
self.calendarViewHeight.constant = bounds.height
self.view.layoutIfNeeded()
}