Skip to content

Commit

Permalink
Fix for #12
Browse files Browse the repository at this point in the history
  • Loading branch information
hons82 committed Nov 5, 2014
1 parent 09d117f commit f462f7c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Install with [CocoaPods](http://cocoapods.org) by adding the following to your P

``` ruby
platform :ios, '6.1'
pod 'THCalendarDatePicker', '~> 0.2.2'
pod 'THCalendarDatePicker', '~> 0.2.3'
```

**Note**: We follow http://semver.org for versioning the public API.
Expand All @@ -36,6 +36,7 @@ Or copy the `THCalendarDatePicker/` directory from this repo into your project.
### V0.2.X

- iOS8 deprecation warnings removed
- Fixed issue [#12](https://github.com/hons82/THCalendarDatePicker/issues/12)
- Fixed issue [#11](https://github.com/hons82/THCalendarDatePicker/issues/11)
- Fixed issue [#7](https://github.com/hons82/THCalendarDatePicker/issues/7)
- Fixed issue [#5](https://github.com/hons82/THCalendarDatePicker/issues/5)
Expand Down
2 changes: 1 addition & 1 deletion THCalendarDatePicker.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "THCalendarDatePicker"
s.version = "0.2.2"
s.version = "0.2.3"
s.summary = "A DatePicker based on a custom calendar view"
s.homepage = "https://github.com/hons82/THCalendarDatePicker"
s.license = { :type => 'MIT', :file => 'LICENSE.md' }
Expand Down
5 changes: 5 additions & 0 deletions THCalendarDatePicker/THDateDay.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ -(void)setLightText:(BOOL)light {
[self.dateButton setTitleColor:color forState:UIControlStateNormal];
self.hasItemsIndicator.image = [UIImage imageNamed:@"calendar_littledot"];
}
[self setCurrentColors];
}

- (IBAction)dateButtonTapped:(id)sender {
Expand All @@ -56,6 +57,10 @@ -(void)setSelected:(BOOL)selected{
[self.dateButton setSelected:NO];
[self.dateButton setTitleColor:[UIColor colorWithWhite:.3 alpha:1] forState:UIControlStateNormal];
}
[self setCurrentColors];
}

- (void)setCurrentColors {
if (self.currentDateColor && [self isToday]) {
[self.dateButton setTitleColor:self.currentDateColor forState:UIControlStateNormal];
}
Expand Down
20 changes: 8 additions & 12 deletions THCalendarDatePicker/THDatePickerViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -202,29 +202,28 @@ - (void)redrawDays {
}

THDateDay * day = [[[NSBundle mainBundle] loadNibNamed:@"THDateDay" owner:self options:nil] objectAtIndex:0];
day.frame = CGRectMake(curX, curY, cellWidth, cellHeight);
day.delegate = self;
day.date = [date dateByAddingTimeInterval:0];
if (self.currentDateColor)
[day setCurrentDateColor:self.currentDateColor];
if (self.currentDateColorSelected)
[day setCurrentDateColorSelected:self.currentDateColorSelected];
if (self.selectedBackgroundColor)
[day setSelectedBackgroundColor:self.selectedBackgroundColor];

[day setLightText:![self dateInCurrentMonth:date]];
[day setEnabled:![self dateInFutureAndShouldBeDisabled:date]];
day.frame = CGRectMake(curX, curY, cellWidth, cellHeight);
day.delegate = self;
day.date = [date dateByAddingTimeInterval:0];
[day indicateDayHasItems:(_dateHasItemsCallback && _dateHasItemsCallback(date))];

if(_internalDate && ![date timeIntervalSinceDate:_internalDate]) {
[day setSelected:YES];
self.currentDay = day;
}

NSDateComponents *comps = [_calendar components:NSCalendarUnitDay fromDate:date];
[day.dateButton setTitle:[NSString stringWithFormat:@"%ld",(long)[comps day]]
forState:UIControlStateNormal];
[self.calendarDaysView addSubview:day];

if (_internalDate && ![date timeIntervalSinceDate:_internalDate]) {
self.currentDay = day;
[day setSelected:YES];
}
// @end
date = [_calendar dateByAddingComponents:offsetComponents toDate:date options:0];
curX += cellWidth;
Expand All @@ -237,9 +236,6 @@ - (void)redrawWeekdays:(int)dayWidth{
int curX = (fullSize.width - 7*dayWidth)/2;
NSDateComponents * comps = [_calendar components:NSCalendarUnitDay fromDate:[NSDate date]];
NSCalendar *c = [NSCalendar currentCalendar];
#ifdef DEBUG
//[c setFirstWeekday:FIRST_WEEKDAY];
#endif
[comps setDay:[c firstWeekday]-1];
NSDateFormatter *df = [[NSDateFormatter alloc] init];
NSDateComponents *offsetComponents = [[NSDateComponents alloc] init];
Expand Down

0 comments on commit f462f7c

Please sign in to comment.