@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];