From 9d7c4808fb0bf92c792c837ecb568ee9dc40a4ad Mon Sep 17 00:00:00 2001 From: Ethan Zhang Date: Mon, 22 May 2017 21:20:56 +0800 Subject: [PATCH] close #86 visible CGRect is wrong when creating event --- CalendarLib/MGCDayPlannerView.m | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CalendarLib/MGCDayPlannerView.m b/CalendarLib/MGCDayPlannerView.m index e51bde89..a3607edb 100755 --- a/CalendarLib/MGCDayPlannerView.m +++ b/CalendarLib/MGCDayPlannerView.m @@ -1142,9 +1142,10 @@ - (CGRect)rectForNewEventOfType:(MGCEventType)type atDate:(NSDate*)date CGFloat x = section * self.dayColumnSize.width; if (type == MGCTimedEventType) { - CGFloat y = [self offsetFromTime:self.durationForNewTimedEvent rounding:0]; - CGRect rect = CGRectMake(x, y, self.dayColumnSize.width, self.interactiveCellTimedEventHeight); - return [self convertRect:rect fromView:self.timedEventsView]; + NSDateComponents *comp = [self.calendar components:NSCalendarUnitHour|NSCalendarUnitMinute fromDate:date]; + CGFloat y = [self offsetFromTime:(comp.hour*3600. + comp.minute*60.) rounding:0]; + CGRect rect = CGRectMake(x, y, self.dayColumnSize.width, self.hourSlotHeight); + return [self convertRect:rect fromView:self.timedEventsView]; } else if (type == MGCAllDayEventType) { CGRect rect = CGRectMake(x, 0, self.dayColumnSize.width, self.allDayEventCellHeight);