2015-04-02 88 views
1

我必须快速为视图着色导航栏,但使用颜色改变颜色变得很困难。视图中的底部颜色是我需要的最终结果,但在viewDidLoad中设置它会导致它不同。任何人都可以指示我的方向?对导航栏使用色调和背景颜色

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 
} 

图像:http://tinypic.com/r/2yo36tw/8

回答

0

我想是因为导航栏是半透明谈到不同。您需要应用该链接中的公式: http://b2cloud.com.au/how-to-guides/bar-color-calculator-for-ios7-and-ios8/ 希望它有帮助。

+0

优秀。不幸的是,我们的设计要求其中一个值低于40,但这比我们的要好得多。谢谢! – 2015-04-02 17:04:42

+0

如果它仍然是实际的,您还可以尝试[BarTintColorOptimizer工具](https://github.com/IvanRublev/BarTintColorOptimizer)以获得优化的导航栏颜色。 对于来自问题的颜色,优化后的颜色是#880f00或'UIColor(红色:0.537096,绿色:0.060848,蓝色:0.002844,alpha:1.0)'。使用它代替原始颜色作为barTintColor属性值,并获得导航栏的正确外观。 – IvanRublev 2015-11-24 18:28:11

相关问题