我的应用程序很大一部分由Web视图组成,以提供本机实现尚不可用的功能。Web团队没有计划为网站实施深色主题。因此,在iOS 13上支持深色模式的情况下,我的应用看起来会一半/一半。
是否可以选择不支持暗模式,以便我们的应用程序始终显示亮模式以匹配网站主题?
假设我的应用程式中有自订颜色:
extension UIColor {
static var myControlBackground: UIColor {
return UIColor(red: 0.3, green: 0.4, blue: 0.5, alpha: 1)
}
}
Run Code Online (Sandbox Code Playgroud)
我在自定义控件(和其他地方)中使用它作为控件的背景:
class MyControl: UIControl {
override init(frame: CGRect) {
super.init(frame: frame)
setup()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
setup()
}
private func setup() {
backgroundColor = .myControlBackground
}
// Lots of code irrelevant to the question
}
Run Code Online (Sandbox Code Playgroud)
对于iOS 13,我希望我的自定义控件同时支持亮模式和暗模式。
一种解决方案是覆盖traitCollectionDidChange
并查看颜色是否已更改,然后根据需要更新我的背景。我还需要提供浅色和深色。
因此,我更新了自定义颜色:
extension UIColor {
static var myControlBackgroundLight: UIColor {
return UIColor(red: 0.3, green: 0.4, blue: 0.5, alpha: …
Run Code Online (Sandbox Code Playgroud) 我将while
backgroundColor NavigationBar
和dark
textColor用于statusBar
,但是当用户将主题iOS更改为深色时,我的textColor statusBar
更改为while
,而while
我的backgroundColor上NavigationBar
则看不到任何东西。如何为我的应用禁用此更改?
在iOS13之前的应用程序布局无法正常工作。苹果在iOS13.1中最新的深色主题和浅色主题更新后,它们在现有应用程序中面临着许多问题。就像UITextField placeHolder和whiteColor以前是blackColor一样,UIDatePicker textColor和whiteColor以前是blackColor。
谁能帮我解决下面的DatePicker文本颜色问题。这是不可见的,因为whiteColor,TextColor应该为blackColor。
任何帮助表示赞赏。谢谢。
您好,我读过Apple文章以禁用“暗模式”,因为我需要为所有UIViewController禁用并且我没有任何BaseUIViewController。
我如何在不使用任何BaseUIViewController的情况下为所有UIViewController禁用暗模式。我不想一遍又一遍地写下面的代码。
这个问题有方法解决吗?
override func viewDidLoad() {
super.viewDidLoad()
// Always adopt a light interface style.
overrideUserInterfaceStyle = .light
}
Run Code Online (Sandbox Code Playgroud) ios13 ×5
ios ×3
ios-darkmode ×2
swift ×2
uicolor ×1
uidatepicker ×1
uikit ×1
uistatusbar ×1
uitextfield ×1
xcode ×1