1

如何使用各种颜色更改选取器内的文本颜色。例如: 在此处输入图像描述

4

2 回答 2

3

使用pickerView:viewForRow, 并返回具有所需颜色的 UILabel

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
    UILabel *label = [[UILabel alloc] init];
    label.text = @"Row";
    label.textColor = [UIColor greenColor];
    return label;
}
于 2012-06-29T11:03:53.013 回答
0

尝试这个:-

 - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view {
        UILabel *demoLbl = (id)view;
        if (!demoLbl) {
            demoLbl= [[[UILabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f, [pickerView rowSizeForComponent:component].width, [pickerView rowSizeForComponent:component].height)] autorelease];
        }

        demoLbl.text = @"Demo";
        demoLbl.textColor = [UIColor redColor];
        demoLbl.font = [UIFont systemFontOfSize:14];
        return demoLbl;
    }
于 2012-06-29T11:08:51.517 回答