在phonegap混编开发中,ios默认是全屏显示,即状态栏也作为phonegape窗口的一部分,但是状态栏默认是白底黑字,这样就与应用主题不吻合。怎么解决这个问题呢,本人最初想实现的是修改状态栏背景色与文字颜色,很遗憾,背景色可以修改但文字颜色始终是黑色,但这个问题在后面得到了解决;另外一种方案就是隐藏状态栏。
[b][color=red]下面就分别说明这两种办法的实现[/color][/b]:
1、修改状态栏样式:
打开Resources/project-info.plist文件,添加或修改配置项Status bar style=Opaque black style。
2、隐藏状态栏:
打开Resources/project-info.plist文件,添加或修改配置项Status bar is initially hidden=YES、View controller-based status bar appearance=NO。
[b][color=red]补充记录[/color][/b]:
Classe文件夹下的MainViewController.m文件中的viewWillAppear方法可以修改为:
[b][color=red]下面就分别说明这两种办法的实现[/color][/b]:
1、修改状态栏样式:
打开Resources/project-info.plist文件,添加或修改配置项Status bar style=Opaque black style。
2、隐藏状态栏:
打开Resources/project-info.plist文件,添加或修改配置项Status bar is initially hidden=YES、View controller-based status bar appearance=NO。
[b][color=red]补充记录[/color][/b]:
Classe文件夹下的MainViewController.m文件中的viewWillAppear方法可以修改为:
- (void)viewWillAppear:(BOOL)animated
{
// View defaults to full size. If you want to customize the view's size, or its subviews (e.g. webView),
// you can do so here.
NSLog(@"systme version:%f", [[[UIDevice currentDevice] systemVersion] floatValue]);
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
CGRect viewBounds = [self.webView bounds];
viewBounds.origin.y = 20;
viewBounds.size.height = viewBounds.size.height - 20;
self.webView.frame = viewBounds;
}
[super viewWillAppear:animated];
}
本人之前从未接触ios开发,大概意思就是针对ios7系统让屏幕窗口的高度减少20,并且位置下移20,即留出20高度的状态栏。