我正在编写一个 Phonegap 3.0+ 应用程序。
iOS7 中状态栏与视图重叠的问题路德维希·克里斯托弗森(Ludwig Kristoffersson)在这里提供了一个可行的答案 https://stackoverflow.com/a/19249775/972191
现在我有了上边距为 20px 的 UIWebView,如何更改 UIWebView 背景颜色?我需要状态栏后面的区域与“人员”工具栏的背景颜色相同。
我几乎没有 Objective C 的经验,并且一直在寻找可能的 SO 问题以找到可行的解决方案,但没有成功。
UIWebView背景颜色 https://stackoverflow.com/questions/6605140/uiwebview-background-color
UIWebView背景设置为Clear Color,但不透明 https://stackoverflow.com/questions/8667150/uiwebview-background-is-set-to-clear-color-but-it-is-not-transparent?lq=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 setOpaque:YES];
//neither of these seem to work when uncommented:
// [self.webView setBackgroundColor:[UIColor grayColor]];
// self.webView.backgroundColor=[UIColor grayColor];
}
[super viewWillAppear:animated];
}
UPDATE 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];
}
这似乎仍然给我状态栏后面的白色背景,而不是灰色。
The result I'm hoping for is like this: