状态栏的字体为黑色:UIStatusBarStyleDefault

状态栏的字体为白色:UIStatusBarStyleLightContent

一、在info.plist中,将View controller-based status bar appearance设为NO

状态栏字体的颜色仅仅由以下的属性设定,默觉得白色:

// default is UIStatusBarStyleDefault

[UIApplication sharedApplication].statusBarStyle

解决个别vc中状态栏字体颜色不同的办法

1、在info.plist中,将View controller-based status bar appearance设为NO.

2、在app delegate中:

[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;

3、在个别状态栏字体颜色不一样的vc中

-(void)viewWillAppear:(BOOL)animated{

[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;

}

-(void)viewWillDisappear:(BOOL)animated

{

[super viewWillDisappear:animated];

[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;

}

二、在info.plist中,将View controller-based status bar appearance设为YES,或者没有设置。

View controller-based status bar appearance的默认值就是YES。

假设View controller-based status bar appearance为YES。

则[UIApplication sharedApplication].statusBarStyle 无效。

用以下的方法:

1、在vc中重写vc的preferredStatusBarStyle方法。

-(UIStatusBarStyle)preferredStatusBarStyle

{

return UIStatusBarStyleDefault;

}

2、在viewDidload中调用:[self setNeedsStatusBarAppearanceUpdate];

可是,当vc在nav中时,上面方法没用,vc中的preferredStatusBarStyle方法根本不用被调用。

原因是,[self setNeedsStatusBarAppearanceUpdate]发出后,

仅仅会调用navigation controller中的preferredStatusBarStyle方法,

vc中的preferredStatusBarStyley方法跟本不会被调用。

解决的方法有两个:

方法一:

设置navbar的barStyle 属性会影响status bar 的字体和背景色。例如以下。

//status bar的字体为白色

//导航栏的背景色是黑色。

self.navigationController.navigationBar.barStyle = UIBarStyleBlack;

//status bar的字体为黑色

//导航栏的背景色是白色,状态栏的背景色也是白色。

//self.navigationController.navigationBar.barStyle = UIBarStyleDefault;

方法二:

自己定义一个nav bar的子类,在这个子类中重写preferredStatusBarStyle方法:

MyNav* nav = [[MyNav alloc] initWithRootViewController:vc];

self.window.rootViewController = nav;

@implementation MyNav

- (UIStatusBarStyle)preferredStatusBarStyle

{

UIViewController* topVC = self.topViewController;

return [topVC preferredStatusBarStyle];

}

在iOS7中改动状态栏字体的颜色的更多相关文章

  1. 在iOS7中修改状态栏字体的颜色

    http://www.2cto.com/kf/201408/324442.html 默认状态栏的字体为黑色:UIStatusBarStyleDefault 状态栏的字体为白色:UIStatusBarS ...

  2. 在iOS7中修改状态栏字体的颜色-b

    状态栏的字体为黑色: UIStatusBarStyleDefault 状态栏的字体为白色: UIStatusBarStyleLightContent 一.在 info.plist  中,将 View ...

  3. iOS7中修改StatusBar的显示颜色

    iOS7中修改StatusBar的显示颜色 效果图如下: 在iOS7中想手动修改statusBar的颜色,第一步需要做的就是在plist文件中设置View controller-based statu ...

  4. 自定义orgmode中加粗字体的颜色

    自定义orgmode中加粗字体的颜色 Table of Contents 1. orgmode中加粗字体的默认处理 2. 设置设置加粗字体的颜色 1 orgmode中加粗字体的默认处理 在orgmod ...

  5. iOS 修改状态栏字体的颜色

    在实际开发中,状态栏有时,需要我们自己设置: 比如: 默认状态栏 假如我们开发的view是黑色的,那么效果如图: 状态栏是白底黑字,下面的view是黑底? 这样子真的好吗?说好的和谐社会呢?说好的开发 ...

  6. MathType中怎么设置字体默认颜色

    MathType功能非常强大,在编辑公式时使用非常方便.利用MathType破解版不仅可以改变公式的字体和字号,也可以改变公式字体颜色.有时在编辑完成后需要对MathType公式格式全部进行修改,这时 ...

  7. MFC中修改静态文本框中文字的字体、颜色

    假设有一个静态文本框控件,其ID为:IDC_STATIC_XSDJ,且关联一个control类的CStatic类型的变量m_static_xsdj. 设置字体时自然要用到CFont类,下面介绍两种方法 ...

  8. vs 中代码的字体也颜色设置

    使用vs之前,需要进行一些常规的配置,以便更加方便自己的使用提高工作效率.字体应该配置为Consolas等宽字体,另外项背景色应设置为自定义淡蓝色(84,91,205),一说这颜色能保护眼睛,确实看的 ...

  9. cocos2d-x JS 富文本(为一段文本中的个别字体上颜色)

    setWinText : function (levelStr1,levelStr2,levelStr3,color1,color2) { var imgRankingBG = this.contai ...

随机推荐

  1. Skype无法显示登录界面

    Skype升级之后突然抽风,双击运行程序之后,输入用户名和密码的窗口都没了,截图如下(本机为Windows 7 32bit版本): 卸载重新安装,也无济于事.删除注册表中的Skype的相关信息后问题依 ...

  2. redis 获取key 过期时间

    <pre name="code" class="html">127.0.0.1:6379> keys *b4f107c6-e96c-4a1e- ...

  3. Mysql 和Oracle rows 区别

    mysql> explain select t1.* from t2 ,t1 where t2.id=t1.id and t2.id<3;\ +----+-------------+--- ...

  4. 让Android中的webview支持页面中的文件上传

    android webview在默认情况下是不支持网页中的文件上传功能的: 如果在网页中有<input type="file" />,在android webview中 ...

  5. 10881 - Piotr's Ants

    Problem D Piotr's Ants Time Limit: 2 seconds "One thing is for certain: there is no stopping th ...

  6. Java使用javax.mail.jar发送邮件并同意发送附件

    因为Java在开发网页上占有绝大优势.所以作为web端的领军人物,譬如发送短信和发送邮件这些就成了必定,网络安全一再安全我们须要把账号的安全级别提到更高.因此这些对于开发者也就成了必须掌握的技能!我一 ...

  7. 程序猿的量化交易之路(26)--Cointrader之Listing挂牌实体(13)

    转载须注明出处:http://blog.csdn.net/minimicall? viewmode=contents,http://cloudtrade.top Listing:挂牌. 比方某仅仅股票 ...

  8. [ExtJS5学习笔记]第第二十四次 Extjs5形式上gridpanel或表单数据后台传输remoteFilter设定

    本文地址:http://blog.csdn.net/sushengmiyan/article/details/39667533 官方文档:http://docs.sencha.com/extjs/5. ...

  9. Redis Destop Manager不能访问虚拟机

    虚拟机centOS中安装Redis,主机Redis Destop Manager不能访问虚拟机Redis server的解决方案 今天在学些redis的时候碰到个问题,发现主机Redis Destop ...

  10. information_schema模式表介绍 processlist

    在mysql里,我们一般通过show (full)processlist查看当前连接情况,处理各种数据库问题.现在在information_schema模式下,5.5以后增加了processlist表 ...