简体   繁体   English

如何自定义导航栏的颜色?

[英]How can I customize the color of the Navigation Bar?

I am BRAND new to iOS development and am building my first app using Xcode 4.3.2 for iOS5. 我是iOS开发的新手,正在使用适用于iOS5的Xcode 4.3.2构建我的第一个应用程序。 I am also using storyboards. 我也在使用情节提要。

I want the background color of my navigation bar to be black instead of the default blue color for all of my views in the storyboard. 我希望导航栏的背景颜色为黑色,而不是情节提要中所有视图的默认蓝色。 I have researched everywhere and cannot find anything that works. 我到处研究过,找不到任何有效的方法。 Either the code generates error messages or its not clear (to me) where to put it. 代码要么生成错误消息,要么(对我而言)不清楚将其放置在何处。 Can anyone help?!!! 有人可以帮忙吗?!!!

Have you tried... 你有没有尝试过...

UIImage *image = [UIImage imageNamed:@"navBarImg.png"];
[self.navigationController.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];

Also check out this -link- for more info relating to your question. 另外,请查看此-link-以获取与您的问题有关的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM