半透明状态栏 (iPhone/iPad/iPod Touch)
我环顾四周,似乎答案是否定的,但这些帖子已经过时了,所以我想知道这是否已经改变。状态栏可以设置成半透明吗?我正在尝试在多点触控点击上执行淡入/淡出效果,但状态栏始终显示为纯黑色。
谢谢!
- 编辑 - 我用于事件转换的代码如下。我已经在-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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
设置
UIApplication
的状态栏样式:状态栏半透明的视图控制器的视图也应占据320 x 480点的整个屏幕尺寸。这样,视图就会覆盖状态栏下方,并且顶部 20 像素中的所有内容都将在状态栏下方半可见。
如果视图中没有任何部分占据顶部 20 像素,它将在下面显示为黑色。
编辑:如果您使用的是 iPad,正如 Steven Fisher 指出的那样,iPad 不支持半透明的黑色状态栏。它始终是纯黑色。
Set the status bar style of
UIApplication
: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.
像这样的东西吗?
Something like this?