Q:

In my iPhone application built with Xcode 5 for iOS 7 I set UIViewControllerBasedStatusBarAppearance=YES in info.plist, and in my ViewController I have this code:

-(UIStatusBarStyle) preferredStatusBarStyle{
returnUIStatusBarStyleLightContent;
}

But the status bar is still black against the black background.

I know its possible to change this app-wide by setting UIViewControllerBasedStatusBarAppearance=NO in info.plist, but I actually need to alter this on a viewController by viewController basis at runtime.

A:

I discovered that if your ViewController is inside a navigationController then the navigationController’s navigationBar.barStyle determines the statusBarStyle.

Setting your navigationBar’s barStyle to UIBarStyleBlackTranslucent will give white status bar text (ie. UIStatusBarStyleLightContent), and UIBarStyleDefault will give black status bar text (ie. UIStatusBarStyleDefault).

Note that this applies even if you totally change the navigationBar’s color via its barTintColor.

http://stackoverflow.com/a/19365160

UIStatusBarStyle PreferredStatusBarStyle does not work on iOS 7的更多相关文章

  1. 14个技巧助你适配 iOS10

    1.Notification(通知) 自从 Notification 被引入之后,苹果就不断的更新优化,但这些更新优化只是小打小闹,直至现在iOS 10开始真正的进行大改重构,这让开发者也体会到 Us ...

  2. 【转】UINavigationBar 使用总结

    原文网址:http://www.jianshu.com/p/f0d3df54baa6 UINavigationBar是我们在开发过程中经常要用到的一个控件,下面我会为大家介绍一些常用的用法. 1. 设 ...

  3. iOS 修改状态栏preferredStatusBarStyle不执行问题

    一.在老版本的iOS中,状态栏永远都是白色风格.而在iOS 7中,我们可以修改每个view controller中状态栏的外观.通过UIStatusBarStyle常量可以指定状态栏的内容是暗色或亮色 ...

  4. iOS中关于NavigationController中preferredStatusBarStyle一直不执行的问题

    重点:真的能改吗?跑起来毛用没有. 1.还要在plist文件里把View controller-based status bar appearance设置成YES. 2.一定要写UINavigatio ...

  5. iOS 小知识点(持续更新)

    1.如何通过代码设置Button  title的字体大小 设置Button.titleLabel.font = [UIFont systemFontOfSize:<#(CGFloat)#> ...

  6. iOS开发 适配iOS10

    2016年9月7日,苹果发布iOS 10.2016年9月14日,全新的操作系统iOS 10将正式上线. 作为开发者,如何适配iOS10呢? 1.Notification(通知) 自从Notificat ...

  7. iOS:小技巧(不断更新)

    记录下一些不常用技巧,以防忘记,复制用. 1.获取当前的View在Window的frame: UIWindow * window=[[[UIApplication sharedApplication] ...

  8. iOS开发 Xcode8中遇到的问题及改动

      iOS开发 Xcode8中遇到的问题及改动 新版本发布总会有很多坑,也会有很多改动. 一个一个填吧... 一.遇到的问题 1.权限以及相关设置 iOS10系统下调用系统相册.相机功能,或者苹果健康 ...

  9. 【转】iOS学习之适配iOS10

    适配iOS10 2016年9月7日,苹果发布iOS 10.2016年9月14日,全新的操作系统iOS 10将正式上线. 作为开发者,如何适配iOS10呢? 1.Notification(通知) 自从N ...

随机推荐

  1. 【机器学习】EM的算法

    EM的算法流程: 初始化分布参数θ: 重复以下步骤直到收敛:         E步骤:根据参数初始值或上一次迭代的模型参数来计算出隐性变量的后验概率,其实就是隐性变量的期望.作为隐藏变量的现估计值: ...

  2. vps 切换内核

    一.安装内核aptitude install linux-image-3.13.0-24-generic linux-headers-3.13.0-24-generic 二.查看已安装的内核dpkg ...

  3. 3. EM算法-高斯混合模型GMM

    1. EM算法-数学基础 2. EM算法-原理详解 3. EM算法-高斯混合模型GMM 4. EM算法-高斯混合模型GMM详细代码实现 5. EM算法-高斯混合模型GMM+Lasso 1. 前言 GM ...

  4. php数组转xml

    0x00 需求 最近要做百度.360.神马搜索的网站sitemap,三家的格式都是xml,然而具体的细节还有有差别的. 一开始用的是dom,没有使用sax,写了几段便觉得太傻了,想到有没有数组转xml ...

  5. spring security 注解@EnableGlobalMethodSecurity详解

     1.Spring Security默认是禁用注解的,要想开启注解,需要在继承WebSecurityConfigurerAdapter的类上加@EnableGlobalMethodSecurity注解 ...

  6. Spark Shuffle 中 JVM 内存使用及配置内幕详情

      本课主题 JVM 內存使用架构剖析 Spark 1.6.x 和 Spark 2.x 的 JVM 剖析 Spark 1.6.x 以前 on Yarn 计算内存使用案例 Spark Unified M ...

  7. strace命令学习

    跟踪一个php程序的运行: strace -s 1000 -f -o test.log php test.php 对于守护进程(后台一直跑的进程) php test.php &   得到它的P ...

  8. SQL复制表操作

    select * into tb1 from tb2 insert into tb1 (fld1, fld2)  select fld1, 0 from tb2 where fld0='x' 以上两句 ...

  9. [Java程序员面试宝典]读书笔记

    ClassLoader具备层次关系,且不止一种.不同的类装载器分布创建的同一个类的字节码数据属于完全不同的对象,没有任何关联 通过Class.forName(String className),能够动 ...

  10. 对于PHP中enum的好奇

    PHP中没有struct.enum这些东西,虽然万能的array用起来很爽,但写出来的代码typo问题很多.可维护性也差,需要更多的测试来辅助,而一旦加上测试的工作量是否还谈得上『爽』就是个问号了. ...