iOS 7 状态栏透明度

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20909051/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 22:58:15  来源:igfitidea点击:

iOS 7 Status bar transparency

iosobjective-cios7statusbar

提问by DCMaxxx

I'm stuck on something that looks trivial, but I really don't understand what's happening.

我被困在一些看起来微不足道的事情上,但我真的不明白发生了什么。

I'm compiling with iOS 7 SDK, and can't get the status bar to be transparent. It's fully black. In my .plist, Status bar styleis Transparent black style (alpha of 0.5). I've tried all the other options, but I couldn't get it to work.

我正在使用 iOS 7 SDK 进行编译,无法使状态栏透明。它是全黑的。在我的 .plist 中,Status bar styleTransparent black style (alpha of 0.5). 我已经尝试了所有其他选项,但我无法让它工作。

I still need to support iOS 6, but I'd expect iOS 7 status bar to be transparent by default, right ?

我仍然需要支持 iOS 6,但我希望 iOS 7 状态栏默认是透明的,对吗?

Any idea on what could cause this ?

关于什么可能导致这种情况的任何想法?

Thanks

谢谢

采纳答案by DCMaxxx

I'll answer to my own question, sorry about the waste of time.

我会回答我自己的问题,抱歉浪费时间。

My mistake was, the status bar wastransparent. But for whatever reason, calling

我的错误是,状态栏透明的。但无论出于何种原因,打电话

[self.navigationController setNavigationBarHidden:YES animated:YES];

changed the top inset of my scrollview from 0.fto 20.f... So, I had a black background under my status bar, and therefore, a black status bar.

将我的滚动视图的顶部插图从0.f更改为20.f... 所以,我的状态栏下方有一个黑色背景,因此,一个黑色状态栏。

Thanks anyway !

不管怎么说,还是要谢谢你 !

回答by Michael Silunsky

Add this code to your .m file:

将此代码添加到您的 .m 文件中:

- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleLightContent;
}

回答by Mauricio Quezada Aspera

hope this helps

希望这可以帮助

self.navigationController.navigationBar.translucent = YES;