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 に答える