【发布时间】:2020-07-14 05:10:20
【问题描述】:
很抱歉,如果有人问过这个问题,但在 stackOverFlow 中找不到正确的答案,所以我问..
我正在尝试在我的应用程序中实现暗模式,但不幸的是,它在使用 tableviews 时对我来说效果不佳,它确实改变了我的背景和内容,但我无法改变我的组的颜色表格视图。
这里有一张图片来说明这个问题: https://imgur.com/a/h4A3zOZ(这里不能上传,太大了)。
这也是我的代码:
// MARK: - Premium Section - DarkMode + Graph:
@IBAction func darkModeSwitch(_ sender: UISwitch) {
let current = sender.isOn ? Theme.dark : Theme.light
if #available(iOS 13.0, *) {
// overrideUserInterfaceStyle = UIUserInterfaceStyle(rawValue: current.stateMode)!
//STEP1: Saving User Defaults Switcher:
saveSwitchToggleDarkMode(switcherState: sender.isOn)
//STEP2: Setting UI Colors Of Settings View:
self.tableView.backgroundColor = current.backgroundColor
///Setting up the barTint Color:
self.navigationController?.navigationBar.barTintColor = current.barTintColor
///Setting up the title text color:
self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor:current.textColor]
///Changing back color in navigation controller:
self.navigationController?.navigationBar.backItem?.backBarButtonItem?.tintColor = current.backItemColor
}
}
【问题讨论】:
标签: swift user-interface ios-darkmode