状态栏的字体为黑色: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. DataGridView ——管理员对用户的那点操作

    记得第一次做机房收费系统的时候,就在加入删除用户这出现了点小问题,由于一直都是一个容不得一点瑕疵的人.所以对查询用户的时候查询一次就会多一些空行我非常是不能容忍.看似非常小的问题,我却花了非常长的时间 ...

  2. POJ 1273 Drainage Ditches(网络流,最大流)

    Description Every time it rains on Farmer John's fields, a pond forms over Bessie's favorite clover ...

  3. fake it till you become it

    fake it till you become it_你泛起山川烟波里的不是我._百度空间 fake it till you become it

  4. 窗口显示于parent控件上(用到了ManualDock函数)

    procedure TForm1.btn1Click(Sender: TObject); begin with TForm2.Create(self) do begin ManualDock(self ...

  5. 《powershell 的版本号所引起的载入 FSharp 编译器问题》基本解决

    <powershell 的版本号所引起的载入 FSharp 编译器问题>基本解决 1.FSharp.Core.dll.不光要 Add-Type,还要在编译中引用.可是,在 VS2012 的 ...

  6. Delphi中类的运行期TypeInfo信息结构说明

    Delphi中类的运行期TypeInfo信息结构说明 CnPack 开源软件项目 2007-09-19 21:55:58 Delphi中类的运行期TypeInfo信息结构说明作者:刘啸CnPack开发 ...

  7. 积累的VC编程小技巧之组合框

    1.如何正确的得到ComBox的指针 CComboBox *mComb = (CComboBox*)GetDlgItem(IDC_DuanCB); CComboBox *mComb = (CCombo ...

  8. LINUX编程学习笔记(十四) 创建进程与 父子进程内存空间

    1什么是进程:进程是一个执行中的程序 执行的程序: 代码->资源->CPU 进程有很多数据维护:进程状态/进程属性 所有进程属性采用的一个树形结构体维护 ps  -a//所有进程 ps - ...

  9. Python学习入门基础教程(learning Python)--5.3 Python写文件基础

    前边我们学习了一下Python下如何读取一个文件的基本操作,学会了read和readline两个函数,本节我们学习一下Python下写文件的基本操作方法. 这里仍然是举例来说明如何写文件.例子的功能是 ...

  10. 鼠标右键怎么清除Catalyst Control Center

    开始→运行→regedit→找到HKEY_CLASSES_ROOT\Directory\Background\shellex\ContextMenuHandlers\ACE→双击并修改其键值 可以删除 ...