ios 中设置状态栏20px的颜色

1.今天有人问我说要设置状态20px的颜色,我当时就懵了回忆起来是不是做过类型的东西,原来是做过,只不过自己没有总结出来现在就总结下出来:

2.在AppdelegateviewController的didFinishLaunchingWithOptions里面添加以下代码:

//设置状态栏背景颜色为黑色

UIView*statusBarInterceptView = [[UIViewalloc]initWithFrame:[UIApplicationsharedApplication].statusBarFrame];

statusBarInterceptView.backgroundColor=[UIColorwhiteColor];

[[[UIApplicationsharedApplication].delegatewindow]addSubview:statusBarInterceptView];

//改变状态栏前景色即时间电量在plist中在info.plist中,将View controller-based status bar appearance设置为NO,白色,YES,黑色

3.在info.plist里面还要添加几个属性如下面的图片所示:


ios 中设置状态栏20px的颜色_第1张图片
info.plist .png

 到这里就行了,你可以测试看看这个效果了!!!

你可能感兴趣的:(ios 中设置状态栏20px的颜色)