iOS datepicker 和 pickerView 设置字体颜色
2017-07-13 11:07
971 查看
pickerView
datePicker
// 设置自定义pickerView label颜色 -(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:NSTextAlignmentCenter]; // [pickerLabel setBackgroundColor:[UIColor clearColor]]; // [pickerLabel setFont:[UIFont boldSystemFontOfSize:15]]; [pickerLabel setTextColor:kPickerViewTitleColor]; } // Fill the label text here pickerLabel.text=[self pickerView:pickerView titleForRow:row forComponent:component]; return pickerLabel; }
datePicker
[self.datePicker setValue:kDatePicerTextColor forKey:@"textColor"]; // 默认选中的颜色 为黑色 修改方法如下 //通过NSSelectorFromString获取setHighlightsToday方法 SEL selector= NSSelectorFromString(@"setHighlightsToday:"); //创建NSInvocation NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDatePicker instanceMethodSignatureForSelector:selector]]; BOOL no = NO; [invocation setSelector:selector]; //setArgument中第一个参数的类picker,第二个参数是SEL, [invocation setArgument:&no atIndex:2]; //让invocation执行setHighlightsToday方法 [invocation invokeWithTarget:self.datePicker];
相关文章推荐
- ios中修改自定义PickerView的字体颜色
- iOS中通过设置CSS改变WebView字体大小,颜色,背景颜色
- DatePicker 设置字体颜色
- pickerView设置字体颜色
- iOS中通过设置CSS改变WebView字体大小,颜色,背景颜色
- iOS中通过设置CSS改变WebView字体大小,颜色,背景颜色
- ios:改变tableview的titleForHeaderInSection字体颜色设置
- ios中修改自定义PickerView的字体颜色
- iOS中设置导航栏标题( titleView)的字体颜色和大小
- Android-PickerView 三级联动选择器的标题和内容的字体大小、颜色设置
- IOS_设置UITableView Section的背景颜色和字体颜色(自定义section布局)
- iOS中通过设置CSS改变WebView字体大小,颜色,背景颜色
- ANDROID TEXTVIEW 设置字体颜色
- android中用Spannable在TextView中设置超链接、颜色、字体
- android中用Spannable在TextView中设置超链接、颜色、字体
- android中用Spannable在TextView中设置超链接、颜色、字体
- android TextView、EditText对部分内容设置颜色、字体、超链接、图片、点击事件
- android 的TextView空间动态设置字体颜色
- Android TextView中文字通过SpannableString来设置超链接、颜色、字体等属性
- android TextView的字体颜色设置的多种方法