半透明状态栏(iPhone / iPad / iPod Touch) [英] Translucent Status Bars (iPhone/iPad/iPod Touch)

查看:176
本文介绍了半透明状态栏(iPhone / iPad / iPod Touch)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在环顾四周,似乎答案是否定的,但帖子已过时,所以我想知道这是否有所改变。是否可以将状态栏设置为半透明?我试图在多点触控水龙头上做淡入/淡出效果,但状态栏不断变成纯黑色。

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.

谢谢!

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

-- 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];
}
}


推荐答案

设置状态栏样式 UIApplication

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

状态栏为半透明的视图控制器视图也应占用整个屏幕尺寸320以480分。这样,视图会重置状态栏,前20个像素中的任何内容都将在状态栏下半可见。

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.

如果您没有任何部分视图占据前20个像素,它将显示为黑色。

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

编辑:如果您正在使用iPad,Steven Fisher指出iPad不支持半透明的黑色状态栏。它总是坚实的黑色。

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.

这篇关于半透明状态栏(iPhone / iPad / iPod Touch)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆