Search code examples
swiftstatusbarnavigationbar

Setting status bar and navigation bar to be the same color


enter image description here

Hi, I wanted to set the status bar to have the exact same color as the UINavigationBar. I am using the exact same color in the code shown below but as you can see from the image, they are not of the same blue color. Is there any method to get them to be the same. I tried to google but could not find any solution.

UIApplication.shared.statusBarView?.backgroundColor = UIColor(red: 13/225, green: 71/255, blue:161/255, alpha: 1.0)

UINavigationBar.appearance().barTintColor = UIColor(red: 13/225, green: 71/255, blue:161/255, alpha: 1.0)

Solution

  • try changing translucent to false

    navigationBar.isTranslucent = false