[英]UIPickerView Font
有谁知道是否可以更改单个UIPickerView项目的字体和/或颜色?
- (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;
}
对的,这是可能的。 为此,您需要在选择器的委托中实现pickerView:viewForRow:forComponent:reusingView:
方法-在pickerView:viewForRow:forComponent:reusingView:
创建UILabel
实例,并使用所需的任何属性对其进行设置。
为此,我将只使用属性字符串。
实现此方法是您的委托:
- (NSAttributedString *)pickerView:(UIPickerView *)pickerView
attributedTitleForRow:(NSInteger)row
forComponent:(NSInteger)component
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.