半透明状态栏 (iPhone/iPad/iPod Touch)

发布于 2024-10-06 13:41:52 字数 1000 浏览 0 评论 0原文

我环顾四周,似乎答案是否定的,但这些帖子已经过时了,所以我想知道这是否已经改变。状态栏可以设置成半透明吗?我正在尝试在多点触控点击上执行淡入/淡出效果,但状态栏始终显示为纯黑色。

谢谢!

- 编辑 - 我用于事件转换的代码如下。我已经在-info.plist中将状态栏设置为半透明,但我注意到IB中没有黑色半透明设置(这可能是我的答案:没有半透明状态栏,除非你是Apple。)

-(IBAction)showOptions:(id)sender
{
if ([UIApplication sharedApplication].statusBarHidden == YES) {
    [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];
    [UIView beginAnimations:@"fadeIn" context:nil];
    [UIView setAnimationDuration:0.25];
    [UIView setAnimationCurve:UIViewAnimationCurveLinear];
    optionsView_portrait.alpha = 0.5;
    [UIView commitAnimations];
}
else
{
    [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];
    [UIView beginAnimations:@"fadeOut" context:nil];
    [UIView setAnimationDuration:0.25];
    [UIView setAnimationCurve:UIViewAnimationCurveLinear];
    optionsView_portrait.alpha = 0.0;
    [UIView commitAnimations];
}
}

I've been looking around and it seems like the answer is no, but the posts are dated so I was wondering if this has changed. Is it possible to set the status bar to translucent? I'm trying to do a fade-in/fade-out effect on a multitouch tap but the status bar keeps coming up as solid black.

Thanks!

-- edit --
The code I'm using for the event transition is below. I have set the statusbar to translucent in the -info.plist, but I noticed there's no Black Translucent setting in IB (which is probably my answer: no translucent statusbar unless you're Apple.)

-(IBAction)showOptions:(id)sender
{
if ([UIApplication sharedApplication].statusBarHidden == YES) {
    [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];
    [UIView beginAnimations:@"fadeIn" context:nil];
    [UIView setAnimationDuration:0.25];
    [UIView setAnimationCurve:UIViewAnimationCurveLinear];
    optionsView_portrait.alpha = 0.5;
    [UIView commitAnimations];
}
else
{
    [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];
    [UIView beginAnimations:@"fadeOut" context:nil];
    [UIView setAnimationDuration:0.25];
    [UIView setAnimationCurve:UIViewAnimationCurveLinear];
    optionsView_portrait.alpha = 0.0;
    [UIView commitAnimations];
}
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夏九 2024-10-13 13:41:52

设置UIApplication的状态栏样式:

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent
                                            animated:YES];

状态栏半透明的视图控制器的视图也应占据320 x 480点的整个屏幕尺寸。这样,视图就会覆盖状态栏下方,并且顶部 20 像素中的所有内容都将在状态栏下方半可见。

如果视图中没有任何部分占据顶部 20 像素,它将在下面显示为黑色。

编辑:如果您使用的是 iPad,正如 Steven Fisher 指出的那样,iPad 不支持半透明的黑色状态栏。它始终是纯黑色。

Set the status bar style of UIApplication:

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent
                                            animated:YES];

The view of the view controller where the status bar is translucent should also occupy the entire screen dimensions of 320 by 480 points. This way, the view underlaps the status bar and anything in the top 20 pixels will be semi-visible under the status bar.

If there isn't any part of your view occupying the top 20 pixels it will show up as black underneath.

EDIT: If you are working with the iPad, as Steven Fisher points out the iPad does not support having a translucent black status bar. It's always solid black.

回忆追雨的时光 2024-10-13 13:41:52

像这样的东西吗?

[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackTranslucent;

Something like this?

[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackTranslucent;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文