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