FSCalendar icon indicating copy to clipboard operation
FSCalendar copied to clipboard

Row height for weekly calendar.

Open BurhanMughal opened this issue 7 years ago • 9 comments

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?

BurhanMughal avatar Mar 30 '17 21:03 BurhanMughal

Screen Shot of my view. screen shot 2017-03-31 at 2 24 52 am

BurhanMughal avatar Mar 30 '17 21:03 BurhanMughal

@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 😃!

captura de pantalla 2017-04-06 a las 18 19 06

MagFer avatar Apr 06 '17 16:04 MagFer

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.

florianthiel avatar Aug 30 '17 12:08 florianthiel

@WenchaoD can you fix it? or accept PR?

brightsider avatar Nov 07 '17 14:11 brightsider

Any plans to merge this in? Facing same problem with week view!

leojkwan avatar Feb 05 '19 07:02 leojkwan

this is my one..I can select calendar dates in two colors Screen Shot 2019-10-28 at 4 56 44 PM

KosalaFMF avatar Oct 28 '19 11:10 KosalaFMF

the same

SpectatorNan avatar Dec 17 '20 06:12 SpectatorNan

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.

lukszar avatar Oct 04 '22 09:10 lukszar

I tried this which worked:

  1. 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 }

  1. set FSCalendar view's scope property to week in ViewDidAppear() override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) calendarView.scope = .week }

  2. 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() }

chitrakush avatar Nov 30 '22 15:11 chitrakush