I created a custom UIPickerView, but I would like UILabel to change color when scrolling to the selected row as follows:

Any ideas?
Edit: What I would like to do is change the color of the UILabel during the selection, i.e. While the wheel is turning, not later.
Here is what I have so far that changed the color of UILabel after you made your choice:
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view { AILabel * pickerRow = view ? (AILabel *)view:[[[AILabel alloc] initWithFrame:CGRectMake(0, 0, 140, 40)] autorelease]; pickerRow.backgroundColor = [UIColor clearColor]; pickerRow.font = [UIFont boldSystemFontOfSize:18.0f]; pickerRow.insets = UIEdgeInsetsMake(0, 10, 0, 0); if(component == 0) { pickerRow.text = [self.numberArray objectAtIndex:row]; if ( row == number ) { pickerRow.alpha = 0.0f; [UIView animateWithDuration: 0.33f delay: 0.0f options: UIViewAnimationOptionCurveEaseOut animations:^{ pickerRow.textColor = [UIColor whiteColor]; pickerRow.shadowColor = [UIColor blackColor]; pickerRow.shadowOffset = CGSizeMake(0.0f, 1.0f); pickerRow.alpha = 1.0f; } completion:^(BOOL finished){ }]; } else { pickerRow.textColor = [UIColor blackColor]; pickerRow.shadowColor = [UIColor whiteColor]; pickerRow.shadowOffset = CGSizeMake(0.0f, 1.0f); } } else { pickerRow.text = [self.durationArray objectAtIndex:row]; if ( row == duration ) { pickerRow.alpha = 0.0f; [UIView animateWithDuration: 0.33f delay: 0.0f options: UIViewAnimationOptionCurveEaseOut animations:^{ pickerRow.textColor = [UIColor whiteColor]; pickerRow.shadowColor = [UIColor blackColor]; pickerRow.shadowOffset = CGSizeMake(0.0f, 1.0f); pickerRow.alpha = 1.0f; } completion:^(BOOL finished){ }]; } else { pickerRow.textColor = [UIColor blackColor]; pickerRow.shadowColor = [UIColor whiteColor]; pickerRow.shadowOffset = CGSizeMake(0.0f, 1.0f); } } return pickerRow; }
AILabel is a regular UILabel, nothing special about it. The variable 'number' is the currently selected value in the first component. "Duration" is the current selected value in the second component.
Hope this is clearer
Greetings
source share