我希望将状态栏的颜色设置为与导航栏相同的颜色。当我尝试将导航栏和状态栏设置为相同的颜色时,导航栏总是比状态栏呈现出较浅的颜色。
这就是我想要的:
导航栏:
这就是我想要的:
我的结果:
在AppDelegate中的代码:
状态栏:
UIApplication.sharedApplication().statusBarStyle = .Default
let statusBar: UIView = UIApplication.sharedApplication().valueForKey("statusBar") as! UIView
if statusBar.respondsToSelector(Selector("setBackgroundColor:"))
{
statusBar.backgroundColor = UIColor(red: 43/255.0, green: 79/255.0, blue: 133/255.0, alpha: 1.0)
statusBar.tintColor = UIColor(red: 43/255.0, green: 79/255.0, blue: 133/255.0, alpha: 1.0)
}
导航栏:
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor()]
UINavigationBar.appearance().backgroundColor = UIColor(red: 43/255.0, green: 79/255.0, blue: 133/255.0, alpha: 1.0)
UINavigationBar.appearance().tintColor = UIColor.whiteColor()
UIApplication.sharedApplication().statusBarHidden = false
UIApplication.sharedApplication().statusBarStyle = .Default
有人能给我提供解决这个问题的建议吗?
先行致谢!
whiteColor
作为色调,而在状态栏上使用UIColor(red: 43/255.0, green: 79/255.0, blue: 133/255.0, alpha: 1.0)
那么简单。 - StudioTime