我想将导航栏色调 Controller 颜色更改为颜色:R:73,G:155,B:255,A:0.7
到目前为止,我只能将其更改为系统中的颜色。这是委托(delegate)中的示例:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
UINavigationBar.appearance().barTintColor = UIColor.blueColor()
UINavigationBar.appearance().tintColor = UIColor.whiteColor()
return true
}
另外,我也希望能够将导航 View Controller 的标题颜色也更改为白色!
如果可能的话,我想将标签栏的色调颜色更改为 R: 73、G: 155、B: 255、A: 0.7,并将它们的文本更改为白色。
最佳答案
如果要设置导航栏的背景颜色:
UINavigationBar.appearance().barTintColor = UIColor.redColor()
请注意 RGB 值介于 0.0 到 1.0 之间,因此您必须将它们除以 255,否则您的颜色将只是白色。下一个色调:
UINavigationBar.appearance().tintColor = UIColor(red: 73.0 / 255.0, green: 155.0 / 255.0, blue: 255.0/ 255.0, alpha: 1.0)
然后设置标题文本:
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName: someColor, NSFontAttributeName: someFont]
最后是条形按钮项目:
UIBarButtonItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: color, NSFontAttributeName: buttonFont], forState: UIControlState.Normal)
关于ios - 快速更改导航 Controller 颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27451977/