UIPickerView设置字体的方法

-(UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{

UILabel *lbl = (UILabel *)view;

if (lbl == nil) {

lbl = [[UILabel alloc]init];

//在这里设置字体相关属性

lbl.font = [UIFont systemFontOfSize:20];

lbl.textColor = [UIColor redColor];

[lbl setTextAlignment:0];

[lbl setBackgroundColor:[UIColor clearColor]];

}

//重新加载lbl的文字内容

lbl.text = [self pickerView:pickerView titleForRow:row forComponent:component];

return lbl;

你可能感兴趣的:(UIPickerView设置字体的方法)