如何更改iOS7 phonegap/cordova应用程序中状态栏的网络视图后面的背景色?
我相信大家都知道,苹果已经改变了iOS7中状态栏的工作方式,这给cordova/phonegap应用程序带来了各种各样的麻烦 如果设备正在运行iOS7,我已使用以下代码将视图向下推了20px:如何更改iOS7 phonegap/cordova应用程序中状态栏的网络视图后面的背景色?,cordova,ios7,statusbar,Cordova,Ios7,Statusbar,我相信大家都知道,苹果已经改变了iOS7中状态栏的工作方式,这给cordova/phonegap应用程序带来了各种各样的麻烦 如果设备正在运行iOS7,我已使用以下代码将视图向下推了20px: if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) { [application setStatusBarStyle:UIStatusBarStyleLightContent]; // handling st
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
[application setStatusBarStyle:UIStatusBarStyleLightContent];
// handling statusBar (iOS6) by leaving top 20px for statusbar.
screenBounds.origin.y = 20;
self.window = [[UIWindow alloc] initWithFrame:screenBounds];
}
else {
self.window = [[UIWindow alloc] initWithFrame:screenBounds];
}
问题是,此代码创建的20px间隙具有如下黑色背景:
如何更改代码创建的此空间的背景色
在my MainViewController.xib中,背景颜色设置为白色。这个黑色背景颜色属性来自哪里
以下是my MainViewController.xib的属性:
非常感谢你真的在使用Phonegap吗 我认为您需要使用CSS在UIWebView的顶部添加边距,而不是向下移动UIWebView 试试这个:
function onDeviceReady() {
if (parseFloat(window.device.version) === 7.0) {
document.body.style.marginTop = "20px";
}
}
document.addEventListener('deviceready', onDeviceReady, false);
是的,我用的是cordova 3.0。我使用了javascript代码,但它不能处理绝对定位的元素。我想找到一个本机解决方案,这样我就不必根据操作系统版本不断地向绝对定位的元素添加条件stlyes。我刚刚在iPhone5上运行了我的应用程序,它的行为与模拟器不同;视图没有被20px按下,背景是白色的。所以这只是模拟器中的一个问题?iOS7模拟器以与iOS6相同的方式显示状态栏,即黑色背景,白色文本,这是正确的,只是我希望黑色背景为白色。在设备上,我向下推视图的代码不知何故被忽略,状态栏是透明的,覆盖了视图,但这是另一个问题!