UIPickerView控件中自定义展示的字体大小及样式

时间:2023-03-09 05:31:06
UIPickerView控件中自定义展示的字体大小及样式

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

UILabel* pickerLabel = (UILabel*)view;

if (!pickerLabel){

pickerLabel = [[UILabel alloc] init];

pickerLabel.adjustsFontSizeToFitWidth = YES;

pickerLabel.font=[UIFont systemFontOfSize:17];

pickerLabel.textAlignment=NSTextAlignmentCenter;

}

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

return pickerLabel;

}