iPhone:具有半透明的黑色uistatusbar的视图布局存在问题 [英] iPhone: problems with translucent black uistatusbar with view layout

查看:106
本文介绍了iPhone:具有半透明的黑色uistatusbar的视图布局存在问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的状态栏有问题.这是iPhone应用程序,而不是iPad应用程序.我想在应用程序中到处都有一个黑色半透明状态栏.

在应用程序plist中设置状态栏样式.设置为黑色半透明.

我的理解是,设置此选项后,所有视图的布局都将从0,0开始,而不是像状态栏不透明时那样从0,20开始.这就是为什么IB为您提供一个选项来指定您将使用哪种状态栏的提示,以便它可以模拟它并在IB中正确显示它. (是的,我在IB中的所有视图都设置为显示黑色半透明状态栏).布局从0,0开始,以便状态栏将覆盖您的视图以显示某些内容.在IB中,它可以正常工作.但是在我的应用中却没有.

我的应用程序是一个基于选项卡栏的应用程序,即使其中的一个视图都正确设置,但其中只有一个视图是正确的.为了使该视图起作用,我必须将背景视图图像设置为0,-20,并且主视图设置为不剪辑子视图".因此,看起来带有黑色半透明的布局无法正常工作.另外,所有其他选项卡视图的设置方式相同,而不是剪辑子视图,并且主背景视图设置为0,-20.但是,只有在第一个标签中,它才能真正起作用".

以下是一些图片:

外观如何(但仍必须将背景设置为0,-20):

具有完全相同设置的另一个标签如下所示:

为确保它是不带背景的清晰半透明状态栏,我尝试了不带背景的情况:

和其他背景(其他背景为纯蓝色,没有轻微的拉丝效果):

因为所有三个不起作用的示例(没有背景,实际和替代)上的状态栏看起来都完全相同,所以我认为状态栏是正确的排序,是黑色半透明的,但后面没有任何内容可以显示出来.

我的几个选项卡都存在此问题,并且使用导航控制器在选项卡中循环浏览的所有视图均存在此问题.它们的设置都与工作"选项卡相同,剪辑子视图"设置为NO,背景原点设置为0,-20

我认为工作中"的图标无法正常工作,而仅仅是由于背景视图中的负偏移量.我认为实际上应该将其设置为0,0并起作用.但是提供的主要IB视图的原点设置为0,20,并且它变灰了,所以我无法更改它.

此外,我在一个选项卡上遇到了另一个问题,在设置"选项卡上,我使用了不同的外观和感觉(看起来更像iPhone),黑色半透明甚至没有生效.我从以编程方式构造的视图开始,它显示了灰色的状态栏:

并向下钻取笔尖支持的视图,它们看起来是一样的:

视图的布局就像是灰色的状态栏,向下20像素(在IB中将其设置为黑色半透明,因此我将其布局为20像素以上)

除了应用程序plist条目外,我还尝试通过编程方式设置状态栏样式,但是(在这些选项卡中的任何一个上)它没有任何作用.

我一直在研究这个问题(Google,stackoverflow,apple.com)数周之久.但没有发现我应该做什么.

ETA:wantsFullScreenLayout解决了其中一个问题,因此我将其标记为已解决.我打开了一个新问题,对这里最初提出的两个问题之一进行了更新,增加了新图片,说明等,并提供了更多适用的标题,因为该问题不是uistatusbar本身.新问题在 新问题

解决方案

我的理解是,设置此选项后,所有视图的布局都将从0,0开始,而不是像具有不透明状态栏时那样从0,20开始."

您从哪儿得到的?应用程序窗口的框架将保持原样,默认情况下为(0,0),并且将停留在该位置–不在乎状态栏的外观.

现在,视图控制器的视图是另一回事.默认情况下,它们的框架设置为UIScreenapplicationFrame属性(换句话说,屏幕的边界减去状态栏所占的面积).这就是为什么您无法让背景色显示在半透明状态栏的后面.

尝试将构成标签栏的每个视图控制器的wantsFullScreenLayout属性设置为 YES .它将根据需要将帧提高到(0,0).

I am having some issues with my status bar. This is an iPhone app, not an iPad app. I would like to have a Black Translucent status bar everywhere in the app.

I have set the status bar style in the app plist. It is set to black translucent.

My understanding is that when this is set, the layout of all the views will start at 0,0 and not 0,20 like it does when you have an opaque status bar. This is why IB gives you the option to specify a hint of what sort of status bar you will be using so it can simulate it and display it correctly in IB. (And yes ALL my views in IB are set to show a black translucent status bar). The layout is done from 0,0 so that the status bar will overlay your view to show something through. And in IB it works fine. But in my app it does not.

My app is a tab bar based app and only one of the views looks correct, even though they are all set up the same. And to get that one view to work, I have to set the background view image to be at 0,-20 with the main view set to NOT clip subviews. So it appears the layout with black translucent is not working right. In addition, all my other tabs views are set the same way, NOT to clip subviews and the main background view set to 0,-20. But only in the 1st tab does this actually "work".

Here are some pictures:

How it should look (but still having to set background to 0,-20):

Another tab, with the exact same settings, looks like this:

To make sure that it was a blacl translucent status bar without a background to overlay, I tried it with no background:

and an alternative background (alternative is straight blue and not with slight brushed effect):

Because the status bar on all three not working examples (no background, actual, and alternative) looks exactly the same, I assume the status bar is correct sort, black translucent, but with nothing behind it to show through.

Several of my tabs all have this problem, and all views that cycle through in the tab with a navigation controller, have this problem. And they are all set the same as the "working" tab with "Clip Subviews" set to NO and the origin of the background set to 0,-20

I think the "working" one is not working but just looks like it is due to the negative offset in the background view. I think it should actually be set to 0,0 and work. But the main IB supplied view has its origin set to 0,20 and it is grayed out so I cannot change it.

Furthermore, I have another problem on one tab, a Settings tab where I use a different look and feel (more iPhone looking), the black translucent is not even taking effect. I start with a programmatically constructed view and it shows a gray status bar:

And drilling down to nib backed views they look the same:

And the views are laid out as if it were a gray statusbar, down 20 pix (where they were set to black translucent in IB so I laid them out 20 pix higher)

I have tried setting the statusbar style programmatically in addition to the app plist entry but it had no effect (on any of these tabs).

I have been researching this (Google, stackoverflow, apple.com) for several weeks, off and on. but have found no indication of what I should be doing.

ETA: wantsFullScreenLayout solved one of the questions, so I am marking this as solved. I have opened a new question with updated issue on one of the two problems originally presented here, with new pics, description, etc and with more applicable title since the problem is not the uistatusbar itself. The new question is at new problem

解决方案

"My understanding is that when this is set, the layout of all the views will start at 0,0 and not 0,20 like it does when you have an opaque status bar."

Where did you get that? The frame of the application's window will stay exactly as it was, by default its at (0,0) and it will stay there - it doesn't care how the status bar looks.

Now the view controller's view, is another thing. By default their frame is set as the applicationFrame property of UIScreen (in other words, the bounds of the screen minus the area occupied by the status bar). That's why you can't get the background color to show behind the translucent status bar.

Try setting the wantsFullScreenLayout property to YES of each view controller that makes up your tab bar. It will bring the frame up to (0,0) as you need it to be.

这篇关于iPhone:具有半透明的黑色uistatusbar的视图布局存在问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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