IOS中修改自定义PickerView的字体颜色

通过重写这个方法来写实现的:

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{  
    UILabel* pickerLabel = (UILabel*)view;  
    if (!pickerLabel){  
        pickerLabel = [[UILabel alloc] init];  
        // Setup label properties - frame, font, colors etc  
        //adjustsFontSizeToFitWidth property to YES  
        pickerLabel.minimumFontSize = 8.;  
        pickerLabel.adjustsFontSizeToFitWidth = YES;  
        [pickerLabel setTextAlignment:UITextAlignmentLeft];  
        [pickerLabel setBackgroundColor:[UIColor clearColor]];  
        [pickerLabel setFont:[UIFont boldSystemFontOfSize:15]];  
    }  
    // Fill the label text here  
    pickerLabel.text=[self pickerView:pickerView titleForRow:row forComponent:component];  
    return pickerLabel;  
}

 

可以修改文字的颜色和背景都可以实现这个方法,希望可以帮到你!!!!!

posted @ 2015-08-20 08:56  朱峰博客  阅读(5490)  评论(0编辑  收藏  举报