其實狀態欄是半透明的。
- (void)webViewDidFinishLoad:(UIWebView *)theWebView
{
// only valid if StatusBarTtranslucent.plist specifies a protocol to handle
if(self.invokeString)
{
// this is passed before the deviceready event is fired, so you can access it in js when you receive deviceready
NSString* jsString = [NSString stringWithFormat:@"var invokeString = \"%@\";", self.invokeString];
[theWebView stringByEvaluatingJavaScriptFromString:jsString];
}
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackTranslucent;
CGRect frame = theWebView.frame;
NSLog(@"The WebView: %f %f %f %f", frame.origin.x, frame.origin.y, frame.size.width, frame.size.height);
frame = theWebView.superview.frame;
NSLog(@"The WebView superview: %f %f %f %f", frame.origin.x, frame.origin.y, frame.size.width, frame.size.height);
frame.size.height += frame.origin.y;
frame.origin.y = 0;
[theWebView.superview setFrame:frame];
return [ super webViewDidFinishLoad:theWebView ];
}
這段代碼的日誌結果表明:
The WebView: 0.000000 0.000000 320.000000 460.000000
The WebView superview: 0.000000 20.000000 320.000000 460.000000
所以固定webview.superview框架,你可以得到UIStatusBarTranslucent
CGRect frame = theWebView.superview.frame;
frame.size.height += frame.origin.y;
frame.origin.y = 0;
[theWebView.superview setFrame:frame];
的感謝您迴應maujee效果。好的'ol * .plist解決方案似乎只適用於默認或黑色設置的渲染應用程序,遺憾的是不適合半透明。我嘗試了所有`AppDelegate.m`函數中的代碼,但似乎它被覆蓋,輕彈回黑色。 – 2012-01-18 14:12:54