如何让iOS中的PhoneGap状态栏变成半透明状态?
我正在使用PhoneGap来构建一个iOS应用程序,并且似乎无法使全屏/半透明状态栏效果起作用。如何让iOS中的PhoneGap状态栏变成半透明状态?
我设置了* -info.plist的Status bar style
到Transparent black style (alpha of 0.5)
,而闪屏了哪些工作。但是当PhoneGap的UIWebView显示时,状态栏会变黑。
我尝试在我的index.html中设置apple-mobile-web-app-status-bar-style
元标记为black-translucent
,但这似乎没有任何效果。
我尝试将phonegap.plist的TopStatusBar
选项设置为blackTranslucent
,但这也没有任何影响。我错过了什么?
你可以尝试在你的Info.plist添加对您的应用程序:
Key: Status bar style
Value: Black translucent style
,或者如果您正在使用原始键值对
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleBlackTranslucent</string>
这个答案是从mwbrooks给出另一个改编对于类似的问题。试一试。
(Phonegap - How do i make the statusbar black?)
或者,也许,在你的** AppDelegate.m你(无效)viewDidLoad方法,你可以把:
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackTranslucent;
其实状态栏是半透明的。
- (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];
这就是它:)谢谢Esepakuto。 – 2012-01-21 03:09:12
的感谢您回应maujee效果。好的'ol * .plist解决方案似乎只适用于默认或黑色设置的渲染应用程序,遗憾的是不适合半透明。我尝试了所有`AppDelegate.m`函数中的代码,但似乎它被覆盖,轻弹回黑色。 – 2012-01-18 14:12:54