美文网首页
状态栏的显示和隐藏,颜色

状态栏的显示和隐藏,颜色

作者: Leon1024 | 来源:发表于2019-01-17 20:53 被阅读0次

一、在APP刚启动时

Launch screen (启动界面)的时候的状态栏显示和隐藏在 info.plist 文件中加入:
Status bar is initially hidden
并设置值(隐藏设YES)
也可以在 TARGETS -> General -> Deployment Info 里勾选 Hide status bar
此设定管启动界面,以及后面的状态。可以被后面的设定颠覆

二、启动图过后的界面

在 info.plist 文件中加入:
View controller-based status bar appearance
并设置值为NO,此时启动后的所有界面都是没有状态栏的。

然后可以在任何想要隐藏或显示的地方加入代码控制:

[UIApplication sharedApplication].statusBarHidden = YES;  // 隐藏
[UIApplication sharedApplication].statusBarHidden = NO;  // 显示
但!

如果 View controller-based status bar appearance 的值设置为YES(默认就是YES)的话,代码再也无法控制。状态栏不能隐藏。

三、如果要显示白色的状态栏:

1、首先需要再info.plist中添加一项View controller-based status bar appearance为no
2、代码控制:[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
如果全局设置,则只要在TARGETS -> General -> Deployment Info 中 Status Bar Style 设置为 Light Content

相关文章

网友评论

      本文标题:状态栏的显示和隐藏,颜色

      本文链接:https://www.haomeiwen.com/subject/fajwdqtx.html