Skip to content

Commit ffee2b1

Browse files
committed
Fix selector background if not provided, and fix warnings
1 parent 689af44 commit ffee2b1

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

Classes/ASDaySelectionView.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ - (void)drawRect:(CGRect)rect
2525
CGContextSetStrokeColorWithColor(context, self.circleColor.CGColor);
2626
CGContextStrokeEllipseInRect(context, circleRect);
2727
}
28+
2829
}
2930

3031
#pragma mark - Private helpers

Classes/ASWeekSelectorView.m

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ - (void)setSelectedDate:(NSDate *)selectedDate animated:(BOOL)animated
8484
completion:
8585
^(BOOL finished) {
8686
self.isAnimating = NO;
87-
[self colorLabelForDate:selectedDate withTextColor:self.selectorLetterTextColor];
87+
if (finished) {
88+
[self colorLabelForDate:selectedDate withTextColor:self.selectorLetterTextColor];
89+
}
8890
}];
8991
}
9092
}
@@ -95,7 +97,8 @@ - (void)setLocale:(NSLocale *)locale
9597
[self updateDateFormatters];
9698
}
9799

98-
- (void)refresh {
100+
- (void)refresh
101+
{
99102
[self rebuildWeeks];
100103
}
101104

@@ -181,7 +184,7 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView
181184
}
182185

183186
// prevent horizontal scrolling
184-
if (offset.y != 0) {
187+
if (fabs(offset.y) > 0.01) {
185188
offset.y = 0;
186189
updatedOffset = YES;
187190
}
@@ -342,7 +345,9 @@ - (void)singleWeekView:(ASSingleWeekView *)singleWeekView didSelectDate:(NSDate
342345
}
343346
completion:
344347
^(BOOL finished) {
345-
[self userDidSelectDate:date];
348+
if (finished) {
349+
[self userDidSelectDate:date];
350+
}
346351
}];
347352
}
348353

@@ -425,7 +430,7 @@ - (void)rebuildWeeks
425430

426431
// determine where the start of the previews week was as that'll be our start date
427432
NSDateComponents *component = [self.gregorian components:NSCalendarUnitWeekday fromDate:self.selectedDate];
428-
NSInteger weekday = [component weekday];
433+
NSUInteger weekday = (NSUInteger) [component weekday];
429434
NSInteger daysToSubtract;
430435
if (weekday == self.firstWeekday) {
431436
daysToSubtract = 0;
@@ -513,7 +518,9 @@ - (void)animateSelectionToPreDrag
513518
^{
514519
self.selectionView.frame = selectionViewFrame;
515520
} completion:^(BOOL finished) {
516-
[self colorLabelForDate:self.selectedDate withTextColor:self.selectorLetterTextColor];
521+
if (finished) {
522+
[self colorLabelForDate:self.selectedDate withTextColor:self.selectorLetterTextColor];
523+
}
517524
}];
518525

519526
self.preDragOffsetX = MAXFLOAT;
@@ -557,7 +564,7 @@ - (ASDaySelectionView *)selectionView
557564
CGFloat height = CGRectGetHeight(self.frame);
558565

559566
ASDaySelectionView *view = [[ASDaySelectionView alloc] initWithFrame:CGRectMake(0, 0, width, height)];
560-
view.backgroundColor = self.selectorBackgroundColor;
567+
view.backgroundColor = self.selectorBackgroundColor ?: [UIColor clearColor];
561568
view.fillCircle = YES;
562569
view.circleCenter = CGPointMake(width / 2, 20 + (height - 20) / 2);
563570
view.circleColor = self.tintColor;

0 commit comments

Comments
 (0)