Ookey Ookey - 4 months ago 12
iOS Question

UINavigationBar is white when it's bg color is set to black

I don't understand why it is so. Here is my code:

UINavigationBar.appearance().backgroundColor = UIColor.blackColor()
UINavigationBar.appearance().translucent = false

Answer

change backgroundColor to barTintColor and

try this

UINavigationBar.appearance().barTintColor = UIColor.blackColor()
UINavigationBar.appearance().translucent = false

e.g

 func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
{
    UINavigationBar.appearance().barTintColor = UIColor.blackColor()
    UINavigationBar.appearance().translucent = false

    return true
}

or use

   self.navigationController!.navigationBar.barTintColor = UIColor.blackColor()
    self.navigationController!.navigationBar.translucent = false

e.g

 override func viewDidLoad() {
    super.viewDidLoad()

    self.navigationController!.navigationBar.barTintColor = UIColor.blackColor()
    self.navigationController!.navigationBar.translucent = false

      }
Comments