zoukankan      html  css  js  c++  java
  • 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;  
    }

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

  • 相关阅读:
    Java 包装类
    CTF 入门笔记
    Java 实践
    Java Object类
    Java 接口
    Java 抽象类
    Java 关键字final
    Java 多态性
    C#类,对象,类成员简介
    C#初始类和命名空间
  • 原文地址:https://www.cnblogs.com/zhufeng1994/p/4744055.html
Copyright © 2011-2022 走看看