UIPickerView字体

有谁知道是否可以更改单个UIPickerView项目的字体和/或颜色?

对的,这是可能的。 要做到这一点,你需要在pickerView:viewForRow:forComponent:reusingView:实现pickerView:viewForRow:forComponent:reusingView:方法 – 在那里创buildUILabel实例,并用你想要的任何属性进行设置。

 - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{ UILabel* tView = (UILabel*)view; if (!tView){ tView = [[UILabel alloc] init]; // Setup label properties - frame, font, colors etc ... } // Fill the label text here ... return tView; } 

为此,我只需使用属性string即可。

实现这个方法是你的委托:

 - (NSAttributedString *)pickerView:(UIPickerView *)pickerView attributedTitleForRow:(NSInteger)row forComponent:(NSInteger)component