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;  
}

 

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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM