我在我的应用程序(特别是 ICViewPager)中使用了视图寻呼机.要使 View Pager 像这样融入导航栏:
I am using a view pager in my app (specifically ICViewPager). To make the View Pager blend into the Navigation bar like so:
我必须将这些代码行放入我的 AppDelegate.m
I had to put these lines of code in my AppDelegate.m
[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
但是,这会导致状态栏与我的导航栏颜色不同.
However, this causes the status bar not to be the same color as my navigation bar.
如何将状态栏的颜色设置为与导航栏的颜色相同?
How do I set the color of my status bar to be the same as my navigation bar?
如何将状态栏的颜色设置为与导航栏的颜色相同?
How do I set the color of my status bar to be the same as my navigation bar?
你没有.状态栏没有颜色.它是透明的.您的工作是让一些具有所需颜色的视图延伸到视图顶部,在状态栏的后面,以便该颜色显示出来.
You don't. The status bar has no color. It is transparent. It is your job to make some view that has the desired color extend up to the top of the view, behind the status bar, so that that color shows through.
例如,此视图可以是您的窗口,也可以是视图控制器的主视图.现在,它是白色的,所以我们看到导航栏顶部上方显示了白色.如果你给你的窗口(或主视图,或者我们看到的任何白色的东西)提供与导航栏相同的颜色,你就会得到你想要的效果.
This view could be your window, for example, or the view controller's main view. Right now, it is white, and so we see the white color show through above the top of the navigation bar. If you give your window (or main view, or whatever the white thing is that we are seeing) the same color as the navigation bar, you'll get the effect you want.
或者,您可以调整导航栏本身的大小和位置,使其到达窗口顶部并覆盖它.
Alternatively, you could adjust the size and position of the navigation bar itself so that it reaches to the top of the window and covers it.
这篇关于iOS 8 - 设置状态栏颜色(当你的 UINavigationBar 有一个零背景图像时)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!