title: Adding dark mode to iOS app
body: <p>I am trying to add a theme to my app (a dark theme). So when the user clicks an activity switch it would then make the whole app go into the dark mode. I have hard coded the dark mode just to see what it would look like; however now I would like to be able to enable and disable it through and UISwitch, but I am not sure how to do this? </p>
  
  <pre><code>class DarkModeTableViewCell: UITableViewCell {
  
  var DarkisOn = Bool()
  let userDefaults = UserDefaults.standard
  
  
  @IBOutlet var darkModeSwitchOutlet: UISwitch!
  
  override func awakeFromNib() {
      super.awakeFromNib()
  
  
  }
  
  override func setSelected(_ selected: Bool, animated: Bool) {
      super.setSelected(selected, animated: animated)
  
      // Configure the view for the selected state
  }
  
  
  @IBAction func darkModeSwitched(_ sender: Any) {
  
      if darkModeSwitchOutlet.isOn == true {
  
          //enable dark mode
  
          DarkisOn = true
  
          userDefaults.set(true, forKey: "DarkDefault")
          userDefaults.set(false, forKey: "LightDefault")
  
  
  
      } else {
  
          //enable light mode
          DarkisOn = false
  
          userDefaults.set(false, forKey: "DarkDefault")
          userDefaults.set(true, forKey: "LightDefault")
      }
  
  }
  
  
  
  }
  
  
  
  class DarkModeViewController: UIViewController {
  
  
  
  func set(for viewController: UIViewController) {
  
  
  
      viewController.view.backgroundColor = UIColor(red: 0.1, green: 0.1, blue: 0.1, alpha: 1.0)
          viewController.navigationController?.navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.white]
      viewController.navigationController?.navigationBar.tintColor =     UIColor.white
      viewController.navigationController?.navigationBar.barStyle =     UIBarStyle.black
      viewController.tabBarController?.tabBar.barStyle = UIBarStyle.black
  
  
  
  
  
  
  }
  static let instance = DarkModeViewController()
  }
  </code></pre>
  
  <p>and then what I do is call the function in each one of the view controllers to see what it looks like, but I need to be able to access the bool value on if the switch is on or off and if it is then have it do that function, otherwise to just keep things the same. If you have any further questions, please let me know, I know some of this might not make to much sense.</p>