我正在编写一个 Phonegap 3.0+ 应用程序。
iOS7 中的状态栏重叠视图存在问题,用户Ludwig Kristoffersson 在此处提供了有效答案
现在我的 UIWebView 的上边距为 20px,如何更改 UIWebView 背景颜色?我需要状态栏后面的区域与“人员”工具栏的背景颜色相同。
我在 Objective C 方面几乎没有经验,并且一直在寻找可能的 SO 问题以找到可行的解决方案,但没有成功。
UIWebView 背景颜色
UIWebView 背景设置为清除颜色,但它不透明
下面是我到目前为止尝试过的代码:
- (void)viewWillAppear:(BOOL)animated {
//Lower screen 20px on ios 7
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;
[self.webView setOpaque:YES];
//neither of these seem to work when uncommented:
// [self.webView setBackgroundColor:[UIColor grayColor]];
// self.webView.backgroundColor=[UIColor grayColor];
}
[super viewWillAppear:animated];
}
更新 1
- (void)viewWillAppear:(BOOL)animated
{
//Lower screen 20px on ios 7
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;
self.webView.backgroundColor = [UIColor grayColor];
self.webView.opaque=NO;
}
[super viewWillAppear:animated];
}
这似乎仍然给了我状态栏后面的白色背景,而不是灰色。
我希望的结果是这样的: