0

I am creating night mode using Swift 4.2(Notification Center ). I followed https://medium.com/@mczachurski/ios-dark-theme-9a12724c112d this tutorial and able change the colour for only labels. check the below list what all things need to change after changing the mode.

  1. Navigation bar
  2. Collection view cell images
  3. Custom cell(.xib) background color

see the below functions

override func enableDarkMode() {
    super.enableDarkMode()

    let navigationBarAppearace = UINavigationBar.appearance()
    navigationBarAppearace.tintColor = UIColor.black
    navigationBarAppearace.barTintColor = UIColor.black
   }

override func enableDarkMode() {
    super.enableDarkMode()

    let navigationBarAppearace = UINavigationBar.appearance()
    navigationBarAppearace.tintColor = UIColor.black
    navigationBarAppearace.barTintColor = UIColor.black
   }
OhStack
  • 106
  • 1
  • 1
  • 15

1 Answers1

0

Are you using the navigation programmatically?, if not you can try with these

self.navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.white]

self.navigationController?.navigationBar.barTintColor  = UIColor.init(red: 40/255, green: 36/255, blue: 96/255, alpha: 1.0);

Hope it will solve your navigation Problem.

For changing the cell color you can refer the link which helped me to solve the issue link

To change the background color of the xib's, refer the code

override func awakeFromNib() {
    backgroundView = UIView()
    backgroundView?.backgroundColor = UIColor.whiteColor()
}
Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
Swift_prasad
  • 65
  • 1
  • 11