diff --git a/TimesSquare/TSQCalendarRowCell.m b/TimesSquare/TSQCalendarRowCell.m index 0cf087b..a3d4587 100644 --- a/TimesSquare/TSQCalendarRowCell.m +++ b/TimesSquare/TSQCalendarRowCell.m @@ -56,7 +56,10 @@ - (void)createDayButtons; NSMutableArray *dayButtons = [NSMutableArray arrayWithCapacity:self.daysInWeek]; for (NSUInteger index = 0; index < self.daysInWeek; index++) { UIButton *button = [[UIButton alloc] initWithFrame:self.contentView.bounds]; - [button addTarget:self action:@selector(dateButtonPressed:) forControlEvents:UIControlEventTouchDown]; + [button addTarget:self action:@selector(dateButtonTouchDown:) forControlEvents:UIControlEventTouchDown]; + [button addTarget:self action:@selector(dateButtonTouchDragExit:) forControlEvents:UIControlEventTouchDragExit]; + [button addTarget:self action:@selector(dateButtonTouchCancel:) forControlEvents:UIControlEventTouchCancel]; + [button addTarget:self action:@selector(dateButtonTouchUpInside:) forControlEvents:UIControlEventTouchUpInside]; [dayButtons addObject:button]; [self.contentView addSubview:button]; [self configureButton:button]; @@ -181,7 +184,19 @@ - (void)setBottomRow:(BOOL)bottomRow; [self setNeedsLayout]; } -- (IBAction)dateButtonPressed:(id)sender; +- (void)resetDateButtonDisplay:(UIButton*)aButton; +{ + aButton.backgroundColor = nil; + [aButton setTitleColor:self.textColor forState:UIControlStateNormal]; +} + +- (void)markDateButtonSelected:(UIButton*)aButton; +{ + aButton.backgroundColor = [UIColor darkGrayColor]; + [aButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; +} + +- (IBAction)dateButtonTouchUpInside:(id)sender; { NSDateComponents *offset = [NSDateComponents new]; offset.day = [self.dayButtons indexOfObject:sender]; @@ -189,6 +204,21 @@ - (IBAction)dateButtonPressed:(id)sender; self.calendarView.selectedDate = selectedDate; } +- (IBAction)dateButtonTouchDown:(id)sender; +{ + [self markDateButtonSelected:sender]; +} + +- (IBAction)dateButtonTouchDragExit:(id)sender; +{ + [self resetDateButtonDisplay:sender]; +} + +- (IBAction)dateButtonTouchCancel:(id)sender; +{ + [self resetDateButtonDisplay:sender]; +} + - (IBAction)todayButtonPressed:(id)sender; { NSDateComponents *offset = [NSDateComponents new];