我想更改导航栏的全局背景颜色。我怎样才能做到这一点?
行:
UINavigationBar.appearance().backgroundColor = UIColor.green
在 application(_:, didFinishLaunchingWithOptions:)
不起作用,同时:
UINavigationBar.appearance().tintColor = UIColor.red
工作正常。
最佳答案
在这种情况下使用色调颜色:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
UINavigationBar.appearance().barTintColor = UIColor.green
UINavigationBar.appearance().tintColor = UIColor.white
UINavigationBar.appearance().titleTextAttributes = [NSAttributedStringKey.foregroundColor:UIColor.white]
return true
}
iOS applies tint color to app icons, tab bars, navigation bars and many other things.
关于ios - 如何更改全局导航栏背景颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53559479/