英文:
Change text color of UIColorPickerViewController?
问题
I do not see any way to change the text color for a UIColorPickerViewController
. Otherwise it's perfect for my needs and would prefer to use it versus making my own picker. I have a light and dark theme for my app and is important that I match the theme.
I've tried the usual hacks like:
myPickerView.setValue(UIColor.red, forKey: "textColor")
But it's not key textColor
compliant and crashes.
Changing the tint color changes the eyedropper icon but no text:
myPickerView.view.tintColor = .cyan
The toolbarItems
property is nil.
I tried overriding preferredStatusBarStyle
:
class MyUIColorPickerViewController: UIColorPickerViewController {
override var preferredStatusBarStyle: UIStatusBarStyle {
return .darkContent
}
}
It has a navigationItem
property, but all of its' properties are nil and navigationController
is nil.
I tried looking at all the subviews of its subviews, but nothing. Seems like there must be a way. Sad Apple doesn't provide us very basic control over its appearance.
英文:
I do not see any way to change the text color for a UIColorPickerViewController
. Otherwise it's perfect for my needs and would prefer to use it versus making my own picker. I have a light and dark theme for my app and is important that I match the theme.
I've tried the usual hacks like:
myPickerView.setValue(UIColor.red, forKey: "textColor")
But it's not key textColor
compliant and crashes.
Changing the tint color changes the eyedropper icon but no text:
myPickerView.view.tintColor = .cyan
The toolbarItems
property is nil.
I tried overriding preferredStatusBarStyle
:
class MyUIColorPickerViewController:UIColorPickerViewController {
override var preferredStatusBarStyle: UIStatusBarStyle {
return .darkContent
}
}
It has a navigationItem
property, but all of its' properties are nil and navigationController
is nil.
I tried looking at all the subviews of its subviews, but nothing. Seems like there must be a way. Sad Apple doesn't provide us very basic control over its appearance.
答案1
得分: 1
如果只是为了匹配您自定义的深色和浅色主题,您可以将overrideUserInterfaceStyle
设置为与.light
/.dark
值匹配的颜色选择器视图控制器。
// 当您处于自己的深色模式时
myPickerView.overrideUserInterfaceStyle = .dark
英文:
If it is just to match your own custom dark and light themes, you can set overrideUserInterfaceStyle
on the color picker view controller to the matching .light
/.dark
value.
// when in your own dark mode
myPickerView.overrideUserInterfaceStyle = .dark
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论