我无法将RGB颜色设置为UINavigationBar
和ToolBar。我试过了
let myColor = UIColor(red: 47, green: 206, blue: 255, alpha: 1.0)
self.navigationController?.navigationBar.barTintColor = myColor
self.navigationController?.toolbar.tintColor = myColor
我也试过HSB颜色
let secondColor = UIColor(hue: 194, saturation: 82, brightness: 100, alpha: 1.0)
self.navigationController?.navigationBar.barTintColor = secondColor
self.navigationController?.toolbar.tintColor = secondColor
但是当我编写以下方法时,它可以工作。
self.navigationController?.navigationBar.barTintColor = UIColor.greenColor()
self.navigationController?.toolbar.tintColor = UIColor.greenColor()
如何将RGB颜色设置为条形?
答案 0 :(得分:3)
let myColor = UIColor(red: 47, green: 206, blue: 255, alpha: 1.0)
不正确。 UIColor
需要0.0 ... 1.0
范围内的颜色分量。所以你可能需要
let myColor = UIColor(red: 47.0/255.0, green: 206.0/255.0, blue: 255.0/255.0, alpha: 1.0)
答案 1 :(得分:0)
UINavigationBar.appearance()。barTintColor = UIColor(红色:73.0 / 255.0,绿色:155.0 / 255.0,蓝色:255.0 / 255.0,alpha:1.0)