JTAppleCalendar icon indicating copy to clipboard operation
JTAppleCalendar copied to clipboard

Non-zero minimum Spacing ignores non-repeating cell size

Open jappleseed69 opened this issue 4 years ago • 8 comments

(Required) Version Number: 8.0.2

Description

Below code worked great until a non-zero minimumLineSpacing was set.

let width = self.view.frame.width
let cellSize = CGFloat(width / 7).rounded()
calendar.cellSize = cellSize
calendarWidthConstraint.constant = cellSize * 7

// Problematic
calendar.minimumLineSpacing = 4

When performing ranged selection, bug mentioned in various issues (e.g. #1147),arises.

Notes

In addition, setting a single property cellSize does not insure cell's aspect ratio to be 1:1. Is this intended and if so, how do I overcome this? Is adjusting the header size an option?

Thanks a bunch and love the package so far 👍

jappleseed69 avatar Oct 24 '19 15:10 jappleseed69

The cells size is determined by by the height for the calendar (if horizontal) or the width of the calendar (if vertical).

As for the lines. What width is your calendar when your app is launched? (you can use the UI debugger to find this)

patchthecode avatar Oct 26 '19 20:10 patchthecode

Seems like the line was caused by a non-circular cornerRadius. So that problem has been resolved!

jappleseed69 avatar Oct 31 '19 16:10 jappleseed69

Regarding a cell whose aspect ratio is 1:1, how would you recommend going about that in a UI like this?

IMG_95A0362A9940-1

jappleseed69 avatar Oct 31 '19 16:10 jappleseed69

You already have your calendar height. Therefore just set the .cellSize to some value that looks good to you.

patchthecode avatar Oct 31 '19 17:10 patchthecode

Please correct me if I'm wrong but .cellSize only dictates the width of the cell, right? If that's the case, I'm not able to set the height of the cell without setting the height of the entire calendar.

However, I'm not sure how I would go about calculating the height of the calendar that would insure me that I would get an 1:1 aspect ratio for my cells.

jappleseed69 avatar Nov 01 '19 15:11 jappleseed69

Have you tried setting the cellSize? If your calendar is a vertical calendar, then this is how you set the cell size.

If you want 1:1 then set the cellSize to calendarWidth/7

patchthecode avatar Nov 01 '19 16:11 patchthecode

That's exactly what I'm doing. It works great when calendar.minimumLineSpacing = 0 but breaks when minimumLineSpacing is a non-zero value. It seems like minimumLineSpacing adds spacing to the lines by subtracting from the existing line height instead of adding additional spacing in between the lines?

btw, thanks a bunch for the quick responses 👍

let width = self.view.frame.width
let cellSize = CGFloat(width / 7).rounded()
calendar.cellSize = cellSize
calendarWidthConstraint.constant = cellSize * 7
calendar.minimumLineSpacing = 4

jappleseed69 avatar Nov 02 '19 22:11 jappleseed69

@jappleseed69 did you resolve this problem?

SajjadKharrazi avatar May 12 '20 21:05 SajjadKharrazi