(一)设置状态栏显示和隐藏
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. java && C# 线程

      1.多个线程用到同一个资源的话,必须lock 2.为了解决,在竞争的情况下,优先分配资源给A.就是A和B线程都同时在同一时刻需要资源x,然后的话也不清楚系统是具体怎样调度的.或者说怎样调度,都有可 ...

  2. gcc 4.9编译

    参考 http://blog.csdn.net/hzhxxx/article/details/28634893

  3. 多级菜单 menu

    jquery menu: http://jqueryui.com/menu/ Kendo UI Demos http://demos.telerik.com/kendo-ui/web/menu/ind ...

  4. DP:凑零钱问题/最长非降子序列(C++)

    你给出一定数额的钱 i 元给我,我利用手中的硬币(m元, j元, k元...)兑换等值的钱给你,要求硬币数最少. 举例:给出1-11的钱,手中硬币有1元,3元,5元. 重点是找到状态和状态转移方程. ...

  5. 关于花瓣网header条的思考

    最近忙着俱乐部招新的事情,每一次培训都会给学员布置作业,但是作业积累在手上并没有长久的保存价值,于是萌生了一个创建俱乐部网站平台的想法.为了充当好PM这个角色,学习了Axure软件的用法,并且首次制作 ...

  6. [PHP]memcache安装

    1.memcached 安装sudo apt-get install memcached memcached 参数说明memcached -d -m 50 -p 11211 -u root-m 指定使 ...

  7. POJ 2594 —— Treasure Exploration——————【最小路径覆盖、可重点、floyd传递闭包】

    Treasure Exploration Time Limit:6000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64 ...

  8. web子项目的路径问题

    http://baidu.com/userms/ userms是一个子应用程序,项目中使用的路径 /content/css/..   从http://baidu.com/  开始 ~/content/ ...

  9. vue-router配置

    首先在App.vue中 1.使用router-link组件来导航,通过‘to'属性指定链接,<router-link> 默认会被渲染成一个 `<a>` 标签 <route ...

  10. 解决dubbo-admin管控台不能显示服务的问题

    1.首先在网上下载了dubbo-admin.war,解压后修改dubbo.properties文件 dubbo.registry.address=zookeeper://127.0.0.1:2181 ...