swiftuinavigationbaruibackgroundcolorbartintcolor

Using Tint and Background Color for NavigationBar


I have to color the navigation bar for a view in swift, but it's becoming difficult to do with the tint altering the color. The bottom color within the view is the final result I need, but setting that in the viewDidLoad causes it to come out different. Any direction anyone can point me in?

override func viewDidLoad() {
    super.viewDidLoad()

    ...

    switch category {
    case "Corn Management":
        // color to be determined
        break
    case "Soybean Management":
        navigationController?.navigationBar.barTintColor = UIColor(red: 153.0/255.0, green: 50.0/255.0, blue: 30.0/255.0, alpha: 1.0)
        break
    default:
        break
    }

    self.title = category
}

image: http://tinypic.com/r/2yo36tw/8


Solution

  • I think it comes different because the navigationbar is translucent. You need to apply the formula from that link: http://b2cloud.com.au/how-to-guides/bar-color-calculator-for-ios7-and-ios8/ Hope it helps.