IOS-OC

UIPickerView设置字体的方法

2016-02-21  本文已影响2874人  请叫我攻城狮

-(UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{

UILabel *lbl = (UILabel *)view;

if (lbl == nil) {

lbl = [[UILabel alloc]init];

//在这里设置字体相关属性

lbl.font = [UIFont systemFontOfSize:20];

lbl.textColor = [UIColor redColor];

[lbl setTextAlignment:0];

[lbl setBackgroundColor:[UIColor clearColor]];

}

//重新加载lbl的文字内容

lbl.text = [self pickerView:pickerView titleForRow:row forComponent:component];

return lbl;

上一篇 下一篇

猜你喜欢

热点阅读