What is the default background color of the navigation bar in iOS 7?

不羁岁月 提交于 2019-11-30 13:41:21

问题


I would like to set the background color of a menu to that of the navigation bar. What is the best way to do this?


回答1:


The default navbar color in iOS 7 is [UIColor colorWithRed:(247.0f/255.0f) green:(247.0f/255.0f) blue:(247.0f/255.0f) alpha:1];




回答2:


To get the tint color of a navigation bar, do this:

[aNavbar barTintColor]

By using this when you set the background color of your menu, you will not have to change it in case you change your navigation bar tint.




回答3:


Swift 5

Nav bar color in light appearance:

UIColor(red: 0.969, green: 0.969, blue: 0.969, alpha: 1.0)



回答4:


Swift 4

I am not sure the color does not change from version to version. In my app I use this:

var navBarDefaultColor: UIColor?

// save:
navBarDefaultColor = self.navigationController?.navigationBar.tintColor

//restore:
self.navigationController?.navigationBar.tintColor = navBarDefaultColor!



回答5:


In Swift, it is:

UIColor(colorLiteralRed: (247/255), green: (247/255), blue: (247/255), alpha: 1)



回答6:


Swift 3.0 +

UIColor(red: (247/255), green: (247/255), blue: (247/255), alpha: 1)




回答7:


You can set the barTintColor to nil to restore to the default white color.



来源:https://stackoverflow.com/questions/19668947/what-is-the-default-background-color-of-the-navigation-bar-in-ios-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!