如何更改 UIDatePicker 色调颜色?
How to change UIDatePicker tint color?
我知道无法自定义 UIDatePicker,但我想知道 iOS 14 Reminders 应用程序如何显示蓝色调而 Calender 显示红色调。
我在 AppDelegate 中将全局色调颜色设置为 .label
,如下所示,但无法为日期选择器设置相同颜色。
UIView.appearance().tintColor = .label
这可能吗?
我观察到的另一个问题是在黑暗模式下,当前日期的天数不可见。如何解决?
提醒和日历分别有蓝色和红色调颜色(强调色)。
UIView.appearance().tintColor = .label
有效。但是, .label 在暗模式下是白色的,并且选择今天日期的文本颜色也是白色的。因此,看起来是这样。使用不同于.label
(白色)的其他颜色进行测试,
你不能做更多,因为你不能改变今天日期的文本颜色。我想它总是白色的。
您可能不需要更改全局色调颜色,datepicker.tintColor = .yourColor
就可以了。
如果您的全局色调颜色是 .label
,请使用 .label
以外的其他颜色作为 UIDatePicker
的色调颜色来解决此问题。
您还可以使用以下方法之一更改全局色调颜色。
UIKit
你需要改变整个App的色调来改变UIDatePicker的色调。
self.window?.tintColor = .primary // .red
在scene(_:willConnectTo:options:)
中使用上面的代码
如果不用SceneDelegate
,就用上面的代码在application(_:didFinishLaunchingWithOptions:)
您也可以在故事板中更改它。
https://stephenradford.me/quick-tip-globally-changing-tint-color-application-wide/
SwiftUI
在资源中更改accentColor。
Change global tint color - iOS7/iOS8
我知道无法自定义 UIDatePicker,但我想知道 iOS 14 Reminders 应用程序如何显示蓝色调而 Calender 显示红色调。
我在 AppDelegate 中将全局色调颜色设置为 .label
,如下所示,但无法为日期选择器设置相同颜色。
UIView.appearance().tintColor = .label
这可能吗?
我观察到的另一个问题是在黑暗模式下,当前日期的天数不可见。如何解决?
提醒和日历分别有蓝色和红色调颜色(强调色)。
UIView.appearance().tintColor = .label
有效。但是, .label 在暗模式下是白色的,并且选择今天日期的文本颜色也是白色的。因此,看起来是这样。使用不同于.label
(白色)的其他颜色进行测试,
你不能做更多,因为你不能改变今天日期的文本颜色。我想它总是白色的。
您可能不需要更改全局色调颜色,datepicker.tintColor = .yourColor
就可以了。
如果您的全局色调颜色是 .label
,请使用 .label
以外的其他颜色作为 UIDatePicker
的色调颜色来解决此问题。
您还可以使用以下方法之一更改全局色调颜色。
UIKit
你需要改变整个App的色调来改变UIDatePicker的色调。
self.window?.tintColor = .primary // .red
在
scene(_:willConnectTo:options:)
中使用上面的代码如果不用
SceneDelegate
,就用上面的代码在application(_:didFinishLaunchingWithOptions:)
您也可以在故事板中更改它。
https://stephenradford.me/quick-tip-globally-changing-tint-color-application-wide/
SwiftUI
在资源中更改accentColor。
Change global tint color - iOS7/iOS8