gpt4 book ai didi

ios - 如何使 iOS 中的 PhoneGap 状态栏变为半透明?

转载 作者:可可西里 更新时间:2023-11-01 05:38:39 25 4
gpt4 key购买 nike

我正在使用 PhoneGap 构建 iOS 应用程序,但似乎无法使全屏/半透明状态栏效果发挥作用。

我将 *-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,但这也没有任何效果。我错过了什么?

最佳答案

实际上状态栏是半透明的。

- (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 frame就可以得到UIStatusBarTranslucent的效果

CGRect frame = theWebView.superview.frame;

frame.size.height += frame.origin.y;
frame.origin.y = 0;

[theWebView.superview setFrame:frame];

关于ios - 如何使 iOS 中的 PhoneGap 状态栏变为半透明?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8511845/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com