(一)设置状态栏显示和隐藏
1、通过 Info.plist 文件增加字段,控制状态栏全局显示和隐藏
  • 在 Info.plist 文件中增加字段 Status bar is initially hidden  设置为 YES ,那么 app 在 LaunchScreen 页面隐藏状态栏
  • 在 Info.plist 文件增加字段 View controller-based status bar appearance 设置为 YES,那么app默认所有页面都会显示状态栏
2、通过代码,控制状态栏全局显示和隐藏
  • 在 Info.plist 文件 View controller-based status bar appearance 设置为 NO时,代码设置状态栏才会起作用。
  • 在 AppDelegate.m 中添加代码 [[UIApplication sharedApplication] setStatusBarHidden:NO];
3、通过代码,控制状态栏局部显示和隐藏
  • 在 Info.plist 文件 View controller-based status bar appearance 设置为 YES
  • 在需要隐藏状态栏的VC中重写写法 - (BOOL)prefersStatusBarHidden { return YES;},返回YES
 
 
(二)设置状态栏颜色
1、设置状态栏文字部分的颜色
  • 全局文字颜色:在 Info.plist 增加key值 Status bar style,value可以设置 UIStatusBarStyleDefault (默认黑色)和 UIStatusBarStyleLightContent (白色)。
  • 全局文字颜色:在 Info.plist 文件 View controller-based status bar appearance 设置为 NO时,且在 AppDelegate.m 中添加2行代码 [[UIApplication sharedApplication] setStatusBarHidden:NO];   [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; 即可!注意:此处 Info.plist中添加的key值对应的value必须为NO,若为YES,则代码不起作用。
  • 局部文字颜色:此处分2种不同情况
           首先设置,在 Info.plist 文件 View controller-based status bar appearance 设置为 YES
           a. ViewController 不嵌套在 UINavigationController 中,需要设置以下
                重写 UIViewController 方法 - (UIStatusBarStyle)preferredStatusBarStyle { return UIStatusBarStyleDefault; }
            b. ViewController 为 UINavigationController 的rootVC,需要设置以下
                继承 UINavigationController 写一个子类,然后重写方法:
                - (UIStatusBarStyle)preferredStatusBarStyle {
                        return self.topViewController.preferredStatusBarStyle;
                }
 
关于以上状态栏的显示和隐藏、文字或背景颜色均为亲测,若存在问题,麻烦留言@我!

Status bar - iOS之状态栏的更多相关文章

  1. 安卓状态栏通知Status Bar Notification

    安卓系统通知用户三种方式: 1.Toast Notification 2.Dialog Notification 3.Status Bar Notification Status Bar Notifi ...

  2. Status bar and navigation bar appear over my view's bounds in iOS 7

    转自:http://stackoverflow.com/questions/17074365/status-bar-and-navigation-bar-appear-over-my-views-bo ...

  3. iOS 使用Method Swizzling隐藏Status Bar

    在iOS 6中,隐藏Status Bar很的简单. // iOS 6及曾经,隐藏状态栏 [[UIApplication sharedApplication] setStatusBarHidden:YE ...

  4. iOS开发-UINavigationBar和Status Bar实用技巧

    iOS7之后关于UINavigationBar和Status  Bar都发生了一系列的改变,如果不需要兼容iOS7之后的设备,按照网上有些资料去解决问题会踩到一些坑.在iOS 7中,我们可以修改每个V ...

  5. iOS Status Bar变换

    http://www.cocoachina.com/ios/20160718/17020.html 背景 iOS 中经常会有需要在某个界面改变状态栏颜色或者某个界面隐藏状态栏的需求.而改变状态栏颜色和 ...

  6. Java基础之扩展GUI——添加状态栏(Sketcher 1 with a status bar)

    控制台程序. 为了显示各个应用程序参数的状态,并且将各个参数显示在各自的面板中,在应用程序窗口的底部添加状态栏是常见且非常方便的方式. 定义状态栏时没有Swing类可用,所以必须自己建立StatusB ...

  7. iOS7隐藏状态栏 status Bar

    转自:http://blog.csdn.net/dqjyong/article/details/17896145 IOS7中,不仅应用的风格有一定的变化,状态栏变化比较大,我们可以看到UIVIEWCO ...

  8. 转 如何在IOS设备中去掉屏幕上的status bar

    引入如何在IOS设备中去掉屏幕上的status bar,即:不显示设备上方的[网络.时间.电池??]条?操作方法一:在-info.list项目文件中,加上“Status bar is initiall ...

  9. Material Design 之 定义状态栏(Status Bar)的颜色

    Hey,好久不见.今天遇到一个问题,想要把Status Bar 和 Tool Bar的颜色弄成一样的,或者是类似的,例如Material Design: 图中Status Bar颜色比Tool Bar ...

随机推荐

  1. inventor安装失败怎样卸载安装inventor 2017?

    AUTODESK系列软件着实令人头疼,安装失败之后不能完全卸载!!!(比如maya,cad,3dsmax等).有时手动删除注册表重装之后还是会出现各种问题,每个版本的C++Runtime和.NET f ...

  2. Kudu的Using Apache Kudu with Apache Impala(官网推荐的步骤)

    不多说,直接上干货! http://kudu.apache.org/docs/kudu_impala_integration.html http://blog.csdn.net/lovebyz/art ...

  3. java.lang.IllegalStateException: FragmentManager is already executing transactions 及 SmartTabLayout复用

    在复用 SmartTabLayout  时, 出现了标题所示的错误.首先我的场景是Activity下两个fragment  :A 和 B,A中使用了SmarttabLayout和viewpager结合 ...

  4. css实现背景透明文字不透明

    设置元素的透明度:  -moz-opacity:0.8; /*在Firefox中设置元素透明度  filter: alpha(opacity=80); /*ie使用滤镜设置透明   但是当我们对一个标 ...

  5. Angularjs ui router,路由嵌套 父controller执行问题

    解决方式来源:https://stackoverflow.com/questions/25316591/angularjs-ui-router-state-reload-child-state-onl ...

  6. nodejs操作文件

    var fs = require('fs'); var txt = "以上程序使用fs.readFileSync从源路径读取文件内容,并使用fs.writeFileSync将文件内容写入目标 ...

  7. 背景图片之background的用法

    常用的background背景属性有: background-color 设置颜色作为对象背景颜色background-image 设置图片作为背景图片background-repeat 设置背景平铺 ...

  8. Design Pattern ->Factory Method

    Layering & Contract Philosophy With additional indirection Factory Method The example code is as ...

  9. http相关文章目录

    四种常见的 POST 提交数据方式  https://imququ.com/post/four-ways-to-post-data-in-http.html

  10. Java问题定位之Java线程堆栈分析

    采用Java开发的大型应用系统越来越大,越来越复杂,很多系统集成在一起,整个系统看起来像个黑盒子.系统运行遭遇问题(系统停止响应,运行越来越慢,或者性能低下,甚至系统宕掉),如何速度命中问题的根本原因 ...