我不明白为什么会这样。这是我的代码:
UINavigationBar.appearance().backgroundColor = UIColor.blackColor()
UINavigationBar.appearance().translucent = false
答案 0 :(得分:1)
将backgroundColor
更改为barTintColor
和
试试这个
UINavigationBar.appearance().barTintColor = UIColor.blackColor()
UINavigationBar.appearance().translucent = false
<强> e.g 强>
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
{
UINavigationBar.appearance().barTintColor = UIColor.blackColor()
UINavigationBar.appearance().translucent = false
return true
}
或使用
self.navigationController!.navigationBar.barTintColor = UIColor.blackColor()
self.navigationController!.navigationBar.translucent = false
<强> e.g 强>
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController!.navigationBar.barTintColor = UIColor.blackColor()
self.navigationController!.navigationBar.translucent = false
}