美文网首页iOS学习记录
[问]iOS开发--状态栏的内容颜色和背景色设置

[问]iOS开发--状态栏的内容颜色和背景色设置

作者: BuzzLightYear23 | 来源:发表于2016-02-26 01:54 被阅读1317次

默认状态下


状态栏的内容为黑色,背景色为白色


想要改变状态栏的字体,电源,运营商等内容的颜色需要


下面代码是将状态栏内容改为白色

在info.plist 文件中更改添加  View controller-based status bar appearance  == NO

然后添加代码,将[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;

想要改变状态栏背景颜色


下面代码是将背景色改为黑色

CGFloatstatwidth = [[UIApplicationsharedApplication]statusBarFrame].size.width;

CGFloatstatheight = [[UIApplicationsharedApplication]statusBarFrame].size.height;

UIView*statusBarView=[[UIViewalloc]initWithFrame:CGRectMake(0,0, statwidth, statheight)];

statusBarView.backgroundColor=[UIColorblackColor];

相关文章

网友评论

    本文标题:[问]iOS开发--状态栏的内容颜色和背景色设置

    本文链接:https://www.haomeiwen.com/subject/sffwkttx.html