我正在寫一個Phonegap 3.0+應用程序。如何在滑動UIWebView以修復iOS7狀態欄覆蓋問題後更改UIWebView背景色?
沒有與狀態欄在iOS7哪個用戶Ludwig Kristoffersson provided a working answer here
現在,我有一個UIWebView一個20像素的頂邊,我怎樣才能改變UIWebView的背景顏色重疊的看法的問題嗎?我需要狀態欄後面的區域與「人員」工具欄的背景顏色相同。
我的目標C幾乎沒有任何經驗,並一直在尋找通過可能的SO問題找到一個有效的解決方案,但沒有成功。
UIWebView background color
UIWebView background is set to Clear Color, but it is not transparent
下面是我試過到目前爲止代碼:
- (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];
}
這似乎仍然給我一個白色背景後面的狀態欄,而不是灰色。
我希望的結果是這樣的:
請看我上面的「更新1」 – Paul
更改顏色和檢查/ – Ganapathy
答案更新更改顏色並檢查一次。 – Ganapathy