UiPickerView change font color according data

Posted by Fulkron on Stack Overflow See other posts from Stack Overflow or by Fulkron
Published on 2010-05-17T15:11:49Z Indexed on 2010/05/17 16:20 UTC
Read the original article Hit count: 627

Filed under:
|
|

I'm using a pickerView with multiple components related to several fields in a Database (CoreData). Is it possible to change the fontcolor for a specific component according the presence of data in the DB ? For example the field in the DB is null the component font color should be RED otherwise black.

Any help will be appreciated !

Dario

================== Thanks Kenny,

I have to apply to a single UIPicker only. So I', returning the view parametere (without modificatiosn). The result is all the pickers show empty rows.

Thanks for help !

Here you will find the code fragment:

  - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view {

if (pickerView == tipoPk){
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100,30)];
label.textColor =      [UIColor redColor];
switch (component) {
case PK_Tipo:
label.text =  [tipoArray objectAtIndex:row]];
break;
case PK_Settore:
label.text =  [settoreArray objectAtIndex:row]];
break;
default:
break;
}
return label;
}
else {
return view;    // <====   return view for non related pickerviews , but no rows shown
}  


}

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about iphone