[英]How to customize the UIDatePicker and change the text color and the background color?
I have created a formatted display of a date object in a table cells and used UIDatePicker to edit those values. 我在表格单元格中创建了日期对象的格式化显示,并使用UIDatePicker编辑这些值。
But I am unable to edit the tint color of the text and the background color. 但我无法编辑文本的色调颜色和背景颜色。
The first screenshot is the actual undesired result: 第一个屏幕截图是实际不需要的结果:
The second screenshot is the desired result: 第二个屏幕截图是所需的结果:
Here is a link to the project : https://www.dropbox.com/sh/m74tnghpqeah8o7/AAA-rMlGe_mhqiuEkDhbApsUa?dl=0 以下是该项目的链接: https : //www.dropbox.com/sh/m74tnghpqeah8o7/AAA-rMlGe_mhqiuEkDhbApsUa?dl=0
@AziCode @AziCode
Add the below line in your func updateDatePicker() , if you like to get the exact color use RGB color coding with UiColor 如果你想使用UiColor获得确切的颜色使用RGB颜色编码,请在func updateDatePicker()中添加以下行
targetedDatePicker.backgroundColor = UIColor.blueColor()
targetedDatePicker.setValue(UIColor.greenColor(), forKeyPath: "textColor")
targetedDatePicker.setValue(0.8, forKeyPath: "alpha")
And refer the link and sample codes for same examples :- http://blog.deeplink.me/post/81386967477/how-to-easily-customize-uidatepicker-for-ios 并参考相同示例的链接和示例代码: - http://blog.deeplink.me/post/81386967477/how-to-easily-customize-uidatepicker-for-ios
can I change the font color of the datePicker in iOS7? 我可以在iOS7中更改datePicker的字体颜色吗?
Normaly i have good idea,but just change font color: Normaly我有个好主意,但只是更改字体颜色:
[self.datePicker setValue:[UIColor whiteColor] forKeyPath:@"textColor"];
SEL selector = NSSelectorFromString( @"setHighlightsToday:" );
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature :
[UIDatePicker
instanceMethodSignatureForSelector:selector]];
BOOL no = NO;
[invocation setSelector:selector];
[invocation setArgument:&no atIndex:2];
[invocation invokeWithTarget:self.datePicker];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.