diff --git a/Example/FSCalendarTestMacros.h b/Example/FSCalendarTestMacros.h index 55d335d..c732ef3 100644 --- a/Example/FSCalendarTestMacros.h +++ b/Example/FSCalendarTestMacros.h @@ -9,7 +9,7 @@ #ifndef FSCalendarTestMacros_h #define FSCalendarTestMacros_h -#define kFSCalendarShouldEnableTestMacros YES +#define FSCalendarShouldEnableTestMacros YES #import "FSCalendarSelectDateTest.h" diff --git a/Example/FullScreenExampleViewController.m b/Example/FullScreenExampleViewController.m index 5a59d6d..41df046 100644 --- a/Example/FullScreenExampleViewController.m +++ b/Example/FullScreenExampleViewController.m @@ -47,6 +47,12 @@ // _calendar.appearance.caseOptions = FSCalendarCaseOptionsWeekdayUsesDefaultCase|FSCalendarCaseOptionsHeaderUsesUpperCase; // }); // [_calendar selectDate:[NSDate fs_dateWithYear:2015 month:9 day:30] scrollToDate:YES]; + + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + NSLog(@"reload"); + [_calendar reloadData]; + // _calendar.appearance.caseOptions = FSCalendarCaseOptionsHeaderUsesDefaultCase|FSCalendarCaseOptionsWeekdayUsesSingleUpperCase; + }); #if 0 FSCalendarTestSelectDate #endif diff --git a/FSCalendar/FSCalendar.m b/FSCalendar/FSCalendar.m index 26b28b0..160732d 100644 --- a/FSCalendar/FSCalendar.m +++ b/FSCalendar/FSCalendar.m @@ -139,14 +139,14 @@ _minimumDate = [NSDate fs_dateWithYear:1970 month:1 day:1]; _maximumDate = [NSDate fs_dateWithYear:2099 month:12 day:31]; - _headerHeight = kFSCalendarAutomaticDimension; - _weekdayHeight = kFSCalendarAutomaticDimension; + _headerHeight = FSCalendarAutomaticDimension; + _weekdayHeight = FSCalendarAutomaticDimension; _calendar = [NSCalendar fs_sharedCalendar]; _firstWeekday = _calendar.firstWeekday; - _preferedHeaderHeight = kFSCalendarAutomaticDimension; - _preferedWeekdayHeight = kFSCalendarAutomaticDimension; - _preferedRowHeight = kFSCalendarAutomaticDimension; + _preferedHeaderHeight = FSCalendarAutomaticDimension; + _preferedWeekdayHeight = FSCalendarAutomaticDimension; + _preferedRowHeight = FSCalendarAutomaticDimension; _scrollDirection = FSCalendarScrollDirectionHorizontal; _firstWeekday = [_calendar firstWeekday]; @@ -692,9 +692,9 @@ _needsAdjustingTextSize = YES; [_collectionViewLayout invalidateLayout]; // Necessary in Swift. Anyone can tell why? - _preferedWeekdayHeight = kFSCalendarAutomaticDimension; - _preferedRowHeight = kFSCalendarAutomaticDimension; - _preferedHeaderHeight = kFSCalendarAutomaticDimension; + _preferedWeekdayHeight = FSCalendarAutomaticDimension; + _preferedRowHeight = FSCalendarAutomaticDimension; + _preferedHeaderHeight = FSCalendarAutomaticDimension; [self setNeedsLayout]; } @@ -919,13 +919,13 @@ - (CGFloat)preferedHeaderHeight { - if (_headerHeight == kFSCalendarAutomaticDimension) { - if (_preferedWeekdayHeight == kFSCalendarAutomaticDimension) { + if (_headerHeight == FSCalendarAutomaticDimension) { + if (_preferedWeekdayHeight == FSCalendarAutomaticDimension) { if (_pagingEnabled) { - CGFloat divider = _scope == FSCalendarScopeMonth ? kFSCalendarStandardMonthlyPageHeight : kFSCalendarStandardWeeklyPageHeight; - _preferedHeaderHeight = (kFSCalendarStandardHeaderHeight/divider)*self.fs_height; + CGFloat divider = _scope == FSCalendarScopeMonth ? FSCalendarStandardMonthlyPageHeight : FSCalendarStandardWeeklyPageHeight; + _preferedHeaderHeight = (FSCalendarStandardHeaderHeight/divider)*self.fs_height; } else { - _preferedHeaderHeight = kFSCalendarStandardHeaderHeight; + _preferedHeaderHeight = FSCalendarStandardHeaderHeight; } } return _preferedHeaderHeight; @@ -935,13 +935,13 @@ - (CGFloat)preferedWeekdayHeight { - if (_weekdayHeight == kFSCalendarAutomaticDimension) { - if (_preferedWeekdayHeight == kFSCalendarAutomaticDimension) { + if (_weekdayHeight == FSCalendarAutomaticDimension) { + if (_preferedWeekdayHeight == FSCalendarAutomaticDimension) { if (_pagingEnabled) { - CGFloat divider = _scope == FSCalendarScopeMonth ? kFSCalendarStandardMonthlyPageHeight : kFSCalendarStandardWeeklyPageHeight; - _preferedWeekdayHeight = (kFSCalendarStandardWeekdayHeight/divider)*self.fs_height; + CGFloat divider = _scope == FSCalendarScopeMonth ? FSCalendarStandardMonthlyPageHeight : FSCalendarStandardWeeklyPageHeight; + _preferedWeekdayHeight = (FSCalendarStandardWeekdayHeight/divider)*self.fs_height; } else { - _preferedWeekdayHeight = kFSCalendarStandardWeekdayHeight; + _preferedWeekdayHeight = FSCalendarStandardWeekdayHeight; } } return _preferedWeekdayHeight; @@ -951,11 +951,11 @@ - (CGFloat)preferedRowHeight { - if (_preferedRowHeight == kFSCalendarAutomaticDimension) { + if (_preferedRowHeight == FSCalendarAutomaticDimension) { CGFloat headerHeight = self.preferedHeaderHeight; CGFloat weekdayHeight = self.preferedWeekdayHeight; CGFloat contentHeight = self.fs_height-headerHeight-weekdayHeight; - CGFloat padding = kFSCalendarStandardWeekdayHeight*0.1; + CGFloat padding = FSCalendarStandardWeekdayHeight*0.1; if (!self.floatingMode) { switch (_scope) { case FSCalendarScopeMonth: { @@ -971,7 +971,7 @@ } } } else { - _preferedRowHeight = kFSCalendarStandardRowHeight; + _preferedRowHeight = FSCalendarStandardRowHeight; } } return _preferedRowHeight; @@ -1000,7 +1000,7 @@ [_weekdays setValue:[UIFont systemFontOfSize:_appearance.weekdayTextSize] forKey:@"font"]; CGFloat width = self.fs_width/_weekdays.count; - CGFloat height = kFSCalendarStandardWeekdayHeight; + CGFloat height = FSCalendarStandardWeekdayHeight; [_weekdays enumerateObjectsUsingBlock:^(UILabel *weekdayLabel, NSUInteger idx, BOOL *stop) { NSUInteger absoluteIndex = ((idx-(_firstWeekday-1))+7)%7; weekdayLabel.frame = CGRectMake(absoluteIndex * width, @@ -1217,7 +1217,6 @@ BOOL shouldSelect = !_supressEvent; if (forPlaceholder) { - // 跨月份选中日期,需要触发各类事件 if (self.allowsMultipleSelection && [self isDateSelected:targetDate]) { // 在多选模式下,点击了已经选中的跨月日期 @@ -1249,6 +1248,7 @@ [cell setNeedsLayout]; _daysContainer.clipsToBounds = NO; [_selectedDates removeLastObject]; + [_collectionView deselectItemAtIndexPath:currentIndexPath animated:NO]; } [_collectionView selectItemAtIndexPath:targetIndexPath animated:YES scrollPosition:UICollectionViewScrollPositionNone]; @@ -1532,9 +1532,9 @@ } - _preferedHeaderHeight = kFSCalendarAutomaticDimension; - _preferedWeekdayHeight = kFSCalendarAutomaticDimension; - _preferedRowHeight = kFSCalendarAutomaticDimension; + _preferedHeaderHeight = FSCalendarAutomaticDimension; + _preferedWeekdayHeight = FSCalendarAutomaticDimension; + _preferedRowHeight = FSCalendarAutomaticDimension; _needsAdjustingViewFrame = YES; [self setNeedsLayout]; } diff --git a/FSCalendar/FSCalendarAppearance.m b/FSCalendar/FSCalendarAppearance.m index 0c91bb2..1d484d5 100644 --- a/FSCalendar/FSCalendarAppearance.m +++ b/FSCalendar/FSCalendarAppearance.m @@ -34,10 +34,10 @@ _autoAdjustTitleSize = YES; - _titleTextSize = kFSCalendarStandardTitleTextSize; - _subtitleTextSize = kFSCalendarStandardSubtitleTextSize; - _weekdayTextSize = kFSCalendarStandardWeekdayTextSize; - _headerTitleTextSize = kFSCalendarStandardHeaderTextSize; + _titleTextSize = FSCalendarStandardTitleTextSize; + _subtitleTextSize = FSCalendarStandardSubtitleTextSize; + _weekdayTextSize = FSCalendarStandardWeekdayTextSize; + _headerTitleTextSize = FSCalendarStandardHeaderTextSize; _headerTitleColor = kBlueText; _headerDateFormat = @"MMMM yyyy"; _headerMinimumDissolvedAlpha = 0.2; @@ -406,9 +406,9 @@ if (_autoAdjustTitleSize) { CGFloat factor = (_calendar.scope==FSCalendarScopeMonth) ? 6 : 1.1; _titleTextSize = _calendar.collectionView.fs_height/3/factor; - _titleTextSize -= (_titleTextSize-kFSCalendarStandardTitleTextSize)*0.5; + _titleTextSize -= (_titleTextSize-FSCalendarStandardTitleTextSize)*0.5; _subtitleTextSize = _calendar.collectionView.fs_height/4.5/factor; - _subtitleTextSize -= (_subtitleTextSize-kFSCalendarStandardSubtitleTextSize)*0.5; + _subtitleTextSize -= (_subtitleTextSize-FSCalendarStandardSubtitleTextSize)*0.5; _headerTitleTextSize = _titleTextSize * 1.25; _weekdayTextSize = _titleTextSize; diff --git a/FSCalendar/FSCalendarCell.m b/FSCalendar/FSCalendarCell.m index fd92faf..2258883 100644 --- a/FSCalendar/FSCalendarCell.m +++ b/FSCalendar/FSCalendarCell.m @@ -75,7 +75,7 @@ [super setBounds:bounds]; CGFloat titleHeight = self.bounds.size.height*5.0/6.0; CGFloat diameter = MIN(self.bounds.size.height*5.0/6.0,self.bounds.size.width); - diameter = diameter > kFSCalendarStandardCellDiameter ? (diameter - (diameter-kFSCalendarStandardCellDiameter)*0.5) : diameter; + diameter = diameter > FSCalendarStandardCellDiameter ? (diameter - (diameter-FSCalendarStandardCellDiameter)*0.5) : diameter; _backgroundLayer.frame = CGRectMake((self.bounds.size.width-diameter)/2, (titleHeight-diameter)/2, diameter, @@ -109,7 +109,7 @@ _backgroundLayer.path = [UIBezierPath bezierPathWithOvalInRect:_backgroundLayer.bounds].CGPath; _backgroundLayer.fillColor = self.colorForBackgroundLayer.CGColor; -#define kAnimationDuration kFSCalendarDefaultBounceAnimationDuration +#define kAnimationDuration FSCalendarDefaultBounceAnimationDuration CAAnimationGroup *group = [CAAnimationGroup animation]; CABasicAnimation *zoomOut = [CABasicAnimation animationWithKeyPath:@"transform.scale"]; diff --git a/FSCalendar/FSCalendarConstance.h b/FSCalendar/FSCalendarConstance.h index 5f07554..812eb5f 100644 --- a/FSCalendar/FSCalendarConstance.h +++ b/FSCalendar/FSCalendarConstance.h @@ -11,18 +11,18 @@ #pragma mark - Constance -UIKIT_EXTERN CGFloat const kFSCalendarStandardHeaderHeight; -UIKIT_EXTERN CGFloat const kFSCalendarStandardWeekdayHeight; -UIKIT_EXTERN CGFloat const kFSCalendarStandardMonthlyPageHeight; -UIKIT_EXTERN CGFloat const kFSCalendarStandardWeeklyPageHeight; -UIKIT_EXTERN CGFloat const kFSCalendarStandardCellDiameter; -UIKIT_EXTERN CGFloat const kFSCalendarAutomaticDimension; -UIKIT_EXTERN CGFloat const kFSCalendarDefaultBounceAnimationDuration; -UIKIT_EXTERN CGFloat const kFSCalendarStandardRowHeight; -UIKIT_EXTERN CGFloat const kFSCalendarStandardTitleTextSize; -UIKIT_EXTERN CGFloat const kFSCalendarStandardSubtitleTextSize; -UIKIT_EXTERN CGFloat const kFSCalendarStandardWeekdayTextSize; -UIKIT_EXTERN CGFloat const kFSCalendarStandardHeaderTextSize; +UIKIT_EXTERN CGFloat const FSCalendarStandardHeaderHeight; +UIKIT_EXTERN CGFloat const FSCalendarStandardWeekdayHeight; +UIKIT_EXTERN CGFloat const FSCalendarStandardMonthlyPageHeight; +UIKIT_EXTERN CGFloat const FSCalendarStandardWeeklyPageHeight; +UIKIT_EXTERN CGFloat const FSCalendarStandardCellDiameter; +UIKIT_EXTERN CGFloat const FSCalendarAutomaticDimension; +UIKIT_EXTERN CGFloat const FSCalendarDefaultBounceAnimationDuration; +UIKIT_EXTERN CGFloat const FSCalendarStandardRowHeight; +UIKIT_EXTERN CGFloat const FSCalendarStandardTitleTextSize; +UIKIT_EXTERN CGFloat const FSCalendarStandardSubtitleTextSize; +UIKIT_EXTERN CGFloat const FSCalendarStandardWeekdayTextSize; +UIKIT_EXTERN CGFloat const FSCalendarStandardHeaderTextSize; #pragma mark - Deprecated diff --git a/FSCalendar/FSCalendarConstance.m b/FSCalendar/FSCalendarConstance.m index 9933618..a90a25d 100644 --- a/FSCalendar/FSCalendarConstance.m +++ b/FSCalendar/FSCalendarConstance.m @@ -8,15 +8,15 @@ #import "FSCalendarConstance.h" -CGFloat const kFSCalendarStandardHeaderHeight = 40; -CGFloat const kFSCalendarStandardWeekdayHeight = 25; -CGFloat const kFSCalendarStandardMonthlyPageHeight = 300.0; -CGFloat const kFSCalendarStandardWeeklyPageHeight = 108+1/3.0; -CGFloat const kFSCalendarStandardCellDiameter = 100/3.0; -CGFloat const kFSCalendarAutomaticDimension = -1; -CGFloat const kFSCalendarDefaultBounceAnimationDuration = 0.15; -CGFloat const kFSCalendarStandardRowHeight = 38+1.0/3; -CGFloat const kFSCalendarStandardTitleTextSize = 13.5; -CGFloat const kFSCalendarStandardSubtitleTextSize = 10; -CGFloat const kFSCalendarStandardWeekdayTextSize = 14; -CGFloat const kFSCalendarStandardHeaderTextSize = 16.5; \ No newline at end of file +CGFloat const FSCalendarStandardHeaderHeight = 40; +CGFloat const FSCalendarStandardWeekdayHeight = 25; +CGFloat const FSCalendarStandardMonthlyPageHeight = 300.0; +CGFloat const FSCalendarStandardWeeklyPageHeight = 108+1/3.0; +CGFloat const FSCalendarStandardCellDiameter = 100/3.0; +CGFloat const FSCalendarAutomaticDimension = -1; +CGFloat const FSCalendarDefaultBounceAnimationDuration = 0.15; +CGFloat const FSCalendarStandardRowHeight = 38+1.0/3; +CGFloat const FSCalendarStandardTitleTextSize = 13.5; +CGFloat const FSCalendarStandardSubtitleTextSize = 10; +CGFloat const FSCalendarStandardWeekdayTextSize = 14; +CGFloat const FSCalendarStandardHeaderTextSize = 16.5; \ No newline at end of file