iOS 8 - 设置状态栏颜色(当你的 UINavigationBar 有一个零背景图像时)

iOS 8 - Set Status Bar Color (when your UINavigationBar has a nil backgroud image)(iOS 8 - 设置状态栏颜色(当你的 UINavigationBar 有一个零背景图像时))
本文介绍了iOS 8 - 设置状态栏颜色(当你的 UINavigationBar 有一个零背景图像时)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序(特别是 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 有一个零背景图像时)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Why local notification is not firing for UNCalendarNotificationTrigger(为什么没有为UNCalendarNotificationTrigger触发本地通知)
iOS VoiceOver functionality changes with Bundle Identifier(IOS画外音功能随捆绑包标识符而变化)
tabbar middle tab out of tabbar corner(选项卡栏中间的选项卡角外)
Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Get an event when UIBarButtonItem menu is displayed(显示UIBarButtonItem菜单时获取事件)