小编A. *_*uel的帖子

打开应用程序的暗模式

我在我的项目 (Swift) 中有一个 TableViewController 和一个 ViewController。我有一个开关可以改变我的应用程序的颜色(变暗)。问题是它只在我所在的场景中改变它。如果我去另一个场景,它是白色的。

我的代码:

import UIKit

class BaseTableViewController: UITableViewController {
    @IBOutlet var InicioTable: UITableView!
    @IBOutlet weak var cell2: UITableViewCell!
    @IBOutlet var viewTable: UITableView!
    @IBOutlet weak var celldarkmode: UITableViewCell!
    @IBOutlet weak var label: UILabel!
    @IBOutlet weak var switchController: UISwitch!

    @IBAction func changeSwitch(_ sender: UISwitch) {
        if switchController.isOn == true
        {
            self.navigationController?.navigationBar.isTranslucent = false
            self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.white]//user global variable
            self.navigationController?.navigationBar.barStyle = UIBarStyle.black //user global variable
            self.navigationController?.navigationBar.tintColor = UIColor.black //user global variable
            UIApplication.shared.statusBarStyle = .lightContent
            label.textColor = UIColor.white
            self.cell2.backgroundColor …
Run Code Online (Sandbox Code Playgroud)

ios swift

2
推荐指数
1
解决办法
2257
查看次数

标签 统计

ios ×1

swift ×1