I'm working on a custom PickerView, i have a two components in the picker (hours, minutes), i have made the "0" in the minutes component gray and not selectable, everything works fine except that the rows are getting reused... my Minutes component showing "0" in gray font (which is what i want) but if you scroll the picker, i see "7, 14, 21....." all in the gray font!! here is my code
enter code here
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
if(component == HOURS) {
NSString *s = [self.arrayOfHours objectAtIndex:row];
return [pickerView viewForShadedLabelWithText:s ofSize:20 forComponent:0 rightAlignedAt:52 reusingView:view];
} else if (component == MINUTES) {
NSString *s = [self.arrayOfMinutes objectAtIndex:row];
return [pickerView viewForShadedLabelWithText:s ofSize:20 forComponent:1 rightAlignedAt:52 reusingView:view];
}
else return 0;
}
- (UIView *)viewForShadedLabelWithText:(NSString *)title ofSize:(CGFloat)pointSize forComponent:(NSInteger)component rightAlignedAt:(CGFloat)offset reusingView:(UIView *)view {
//.........................
label = [self shadedLabelWithText:title ofSize:pointSize :component];
//..........................
}
- (UILabel *)shadedLabelWithText:(NSString *)label ofSize:(CGFloat)pointSize :(NSInteger)component
{
UILabel *labelView = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
labelView.text = label;
if([label isEqual:@"0"] && component == 1) {
labelView.textColor = [UIColor grayColor];
}
return labelView;
}
1 - Can someone please help me avoid picker view to reuse rows?
2 - How can i make the picker view show rows in round/circular ??