如何在 iOS 6 上设置状态栏色调颜色?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12467794/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to set status bar tint color on iOS 6?
提问by Anton
As shown on Apple's September 2012 keynote, the status bar tint color varies between apps in iOS 6. For instance, Safari and Maps use a black status bar whereas Mail adds a blue tint to it.
如 Apple 2012 年 9 月的主题演讲所示,iOS 6 中的应用程序的状态栏色调颜色各不相同。例如,Safari 和地图使用黑色状态栏,而邮件则添加蓝色色调。
Is it possible to set that tint color, or at least force it to black?
是否可以设置该色调颜色,或者至少将其强制为黑色?
回答by KDaker
You can do it from the plist like Comradsky mention or in xcode 4.5, they added an option for it in the project summary.
您可以从像 Comradsky 提及的 plist 或在 xcode 4.5 中执行此操作,他们在项目摘要中为其添加了一个选项。
Update:
更新:
several people were confused by this answer. Just to clarify, you cannot set the status bar tint to any color you want. What is described above is only to change the status bar tint during launch and choose the iOS 6 default status bar color behavior (which picks the color of the bottom row of pixels from your navigation bar).
很多人都被这个答案弄糊涂了。只是为了澄清,您不能将状态栏色调设置为您想要的任何颜色。上面描述的只是在启动期间更改状态栏色调并选择 iOS 6 默认状态栏颜色行为(从导航栏中选择底部行像素的颜色)。
回答by Geoffroy
I've just found how to do it !
我刚刚找到了怎么做!
- In your "Project Summary", in "Status Bar", set "Style" and "Tinting" to "Default.
- Then, jump into you xib or storyboard and add a
UINavigationBar
just below the status bar. - Set the
UINavigationBar
"Style" to "Default" and select the "Tinting" of your choice. - Run! :-)
- 在“项目摘要”的“状态栏”中,将“样式”和“着色”设置为“默认”。
- 然后,跳转到您的 xib 或故事板并
UINavigationBar
在状态栏正下方添加一个。 - 将
UINavigationBar
“样式”设置为“默认”并选择您选择的“着色”。 - 跑!:-)
If, like me, you don't want any UINavigationBar
visible in your Interface, all you want to do is putting the UINavigationBar
behind all the Objects, or set the "Alpha" to zero.
如果像我一样,你不想UINavigationBar
在你的界面中看到任何东西,你要做的就是把UINavigationBar
所有对象放在后面,或者将“Alpha”设置为零。
回答by Vineeth
You can do that in a tricky way..
你可以用一种棘手的方式做到这一点..
- In the Project Summary select Status Bar Style Black Transculent from the drop down menu.
In
application: didFinishLaunchingWithOptions:
enter the following line of code:self.window.backgroundColor = [UIColor greenColor];
//example color
- 在 Project Summary 中,从下拉菜单中选择 Status Bar Style Black Transculent。
在
application: didFinishLaunchingWithOptions:
输入以下代码行:self.window.backgroundColor = [UIColor greenColor];
//示例颜色
It works fine for me.
这对我来说可以。
回答by Twilite
The tint color seems to be determined by the average color of the bottom pixel row of the app's header bar.
色调颜色似乎由应用程序标题栏底部像素行的平均颜色决定。
See here: http://www.cultofmac.com/173928/how-ios-6s-cool-new-adaptive-status-bar-works/
见这里:http: //www.cultofmac.com/173928/how-ios-6s-cool-new-adaptive-status-bar-works/
回答by PiView
It is very easy to do: just put up an UINavigationBar in your .xib/storyboard, make sure the style is default. then add a tint. no matter how many views, with different tinted UINavigationBar's, you have your status bar will change its color.
这很容易做到:只需在你的 .xib/storyboard 中放置一个 UINavigationBar,确保样式是默认的。然后添加色调。无论有多少视图,使用不同颜色的 UINavigationBar,您的状态栏都会改变其颜色。
回答by Comradsky
There is no way in iOS 5. You can just change your bar style. In iOS 6 you can do it in the info.plist:
iOS 5 没有办法。你可以改变你的酒吧风格。在 iOS 6 中,您可以在 info.plist 中执行此操作:
It is now possible to set status bar tint parameters in your app's Info.plist file. You might do this to ensure that the status bar color matches the navigation bar color of your app during startup. To set the status bar tint, add the UIStatusBarTintParameters key to your Info.plist file. The value of this key is a dictionary with the appropriate values describing the navigation bar your app has at startup time. Inside the dictionary should be the UINavigationBar key, whose value is also a dictionary. That dictionary contains the initial navigation bar's style (with the Style key) and whether it's translucent (with the Translucent key). If your navigation bar uses them, you can also specify its tint color (with the TintColor key), or the name of its custom background image (with the BackgroundImage key).
现在可以在应用程序的 Info.plist 文件中设置状态栏色调参数。您可以这样做以确保在启动期间状态栏颜色与应用程序的导航栏颜色匹配。要设置状态栏色调,请将 UIStatusBarTintParameters 键添加到您的 Info.plist 文件中。此键的值是一个字典,其中包含描述应用程序在启动时的导航栏的适当值。字典里面应该是 UINavigationBar 键,它的值也是一个字典。该字典包含初始导航栏的样式(使用 Style 键)以及它是否是半透明的(使用 Translucent 键)。如果您的导航栏使用它们,您还可以指定其色调颜色(使用 TintColor 键)或其自定义背景图像的名称(使用 BackgroundImage 键)。
Check out this link hereEdit:You can also do this in the project summary.
在此处查看此链接编辑:您也可以在项目摘要中执行此操作。