UIPickerViewのテキストの色を白に変更する方法を知っている人がいるかと思います。私のコードは以下の通りです:iOSでUIPickerViewのテキストの色を白に変更する方法
コード:
(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
[self.pickerView setValue:[UIColor whiteColor] forKey:@"textColor"];
}
任意のアイデア?
が- (NSAttributedString *)pickerView:(UIPickerView *)pickerView attributedTitleForRow:(NSInteger)row forComponent:(NSInteger)component
{
NSString *title = @"sample title";
NSAttributedString *attString = [[NSAttributedString alloc] initWithString:title attributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
return attString;
}
- (UIViewの*)pickerView:(UIPickerView *)pickerViewをviewForRow:(NSInteger)row forComponent:(NSInteger)コンポーネントreusingView:(UIView *)ビュー { UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(0、0、pickerView.frame.size.width、44)]; label.backgroundColor = [UIColor clearColor]; label.textColor = [UIColor WhiteColor]; label.font = [UIFont fontWithName:@ "HelveticaNeue-Bold" size:18]; label.text = [NSString stringWithFormat:@ "%c"、65 + row]; // ASCII 65は "A" リターンラベルです。 } ありがとう – Nimmy