我已经在表格单元格中创建了一个日期对象的格式化显示,并使用UIDatePicker来编辑这些值。但是我无法编辑文本的色调和背景颜色。第一张截图是实际不希望得到的结果:
第二张截图是期望的结果:
这是项目的链接:https://www.dropbox.com/sh/m74tnghpqeah8o7/AAA-rMlGe_mhqiuEkDhbApsUa?dl=0。
![The actual UIDatepicker](https://istack.dev59.com/YwQIx.webp)
第二张截图是期望的结果:
![enter image description here](https://istack.dev59.com/6kEcG.webp)
@AziCode
如果您想获得准确的颜色,请在您的 "func updateDatePicker()" 中添加以下行,并使用 UiColor 的 RGB 颜色编码。
targetedDatePicker.backgroundColor = UIColor.blueColor()
targetedDatePicker.setValue(UIColor.greenColor(), forKeyPath: "textColor")
targetedDatePicker.setValue(0.8, forKeyPath: "alpha")
请参考以下链接和示例代码,了解相关示例:
http://blog.deeplink.me/post/81386967477/how-to-easily-customize-uidatepicker-for-ios通常我有很好的想法,但只是改变字体颜色:
[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];