简体   繁体   English

无法在iOS中获得半透明状态栏

[英]Can't get a translucent status bar in iOS

I'm trying to get the standard black translucent status bar in my iOS (iOS 6) app programmatically with no luck. 我试图以编程方式在我的iOS(iOS 6)应用程序中获得标准的黑色半透明状态栏,但没有运气。 I tried adding the key/value in my info.plist, as well as adding... 我尝试在info.plist中添加键/值,以及添加...

[[UIApplication sharedApplication]setStatusBarStyle:UIStatusBarStyleBlackTranslucent];

...to no effect. ......没有效果。 What else could be causing this? 还有什么可能导致这个?

Thank you everyone for your input! 谢谢大家的意见! You can set it in the info.plist, or use 您可以在info.plist中设置它,或使用

[[UIApplication sharedApplication]setStatusBarStyle:UIStatusBarStyleBlackTranslucent];

Turns out it was translucent - there was just nothing underneath. 原来它是半透明的 - 下面什么都没有。 What i was missing was this line in my view controller 我缺少的是我的视图控制器中的这一行

self.wantsFullScreenLayout = YES;

and thats it! 这就是它!

  1. Delete that line of code. 删除该行代码。
  2. Click on the project file in the project navigator. 单击项目导航器中的项目文件。
  3. Select your target. 选择目标。
  4. Go to "Summary" tab. 转到“摘要”标签。
  5. Select the status bar style from the drop down. 从下拉列表中选择状态栏样式。

Have a look at my answer to this question . 看看我对这个问题的回答

Basically you can change the statusBar in the project summary. 基本上,您可以在项目摘要中更改statusBar。 Here you can select Status Bar Style Black Transculent from the drop down menu. 在这里,您可以从下拉菜单中选择Status Bar Style Black Transculent。

you have got the code right. 你有正确的代码。 place it in your app delegate in application did finish launching with an option and it should do the trick. 将它放在应用程序中的应用程序委托中完成启动选项,它应该做的伎俩。 i just built a simple view application and just added your code to the app delegate and added an image to the view to test it and it works. 我刚刚构建了一个简单的视图应用程序,只是将您的代码添加到应用程序委托中,并将一个图像添加到视图中以测试它并且它可以工作。 you can see it in screen shot below. 你可以在下面的屏幕截图中看到它。

在此输入图像描述

good luck. 祝好运。

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

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