自定义UIPickerView修改显示样式

来源:互联网 发布:淘宝开店收费吗2016 编辑:程序博客网 时间:2024/06/05 06:24
//重写UIPickerViewDataSource中的这个方法- (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 setTextAlignment:NSTextAlignmentCenter];        [pickerLabel setBackgroundColor:[UIColor clearColor]];        [pickerLabel setFont:[UIFont boldSystemFontOfSize:16]];    }    // Fill the label text here    pickerLabel.text=[self pickerView:pickerView titleForRow:row forComponent:component];    return pickerLabel;}
0 0
原创粉丝点击