可以在iOS7中更改datePicker的字体颜色吗? [英] can I change the font color of the datePicker in iOS7?

查看:127
本文介绍了可以在iOS7中更改datePicker的字体颜色吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

刚刚下载了我的xcode 5的副本,并且想知道是否有人知道如何更改日期选择器中字体的颜色或大小?

解决方案(UIView *)pickerView:(UIPiewView *)pickerView viewForRow :( NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view {

UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(0,0,pickerView.frame.size.width,44)];
label.backgroundColor = [UIColor grayColor];
label.textColor = [UIColor whiteColor];
label.font = [UIFont fontWithName:@HelveticaNeue-Boldsize:18];
label.text = [NSString stringWithFormat:@%d,row + 1];
返回标签;
}

//组件数量
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
return 1;
}

//组件中的行数
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
return 6;
}


just downloaded my copy of xcode 5 and was wondering if anyone knows how I can change the color or size of the font in the date picker?

解决方案

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

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, pickerView.frame.size.width, 44)];
label.backgroundColor = [UIColor grayColor];
label.textColor = [UIColor whiteColor];
label.font = [UIFont fontWithName:@"HelveticaNeue-Bold" size:18];
label.text = [NSString stringWithFormat:@" %d", row+1];
return label;    
}

// number Of Components
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
return 1;
}

// number Of Rows In Component
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:   (NSInteger)component{
return 6;
}

这篇关于可以在iOS7中更改datePicker的字体颜色吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆