iPhone:半透明黑色 uistatusbar 与视图布局的问题

发布于 2024-11-24 18:25:24 字数 2016 浏览 1 评论 0 原文

我的状态栏有一些问题。这是 iPhone 应用程序,而不是 iPad 应用程序。我希望应用程序中的任何地方都有一个黑色半透明状态栏。

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

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

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

下面是一些图片:

它应该是什么样子(但仍然必须将背景设置为 0,-20): 这就是它应该的样子

另一个选项卡具有完全相同的设置,如下所示:bad another tab

为了确保它是一个没有背景覆盖的 blacl 半透明状态栏,我在没有背景的情况下尝试了它:

和替代背景(替代方案是纯蓝色,没有轻微的拉丝效果):alternative background

​​ 因为所有三个不起作用的示例(无背景、实际和替代)上的状态栏看起来完全相同,所以我假设状态栏排序正确,黑色半透明,但带有其背后没有什么可以显示出来的。

我的几个选项卡都有这个问题,并且使用导航控制器在选项卡中循环的所有视图都有这个问题。它们的设置与“工作”选项卡相同,“剪辑子视图”设置为“否”,背景原点设置为 0,-20

我认为“工作”选项卡不起作用,但看起来像是应该的到背景视图中的负偏移量。我认为它实际上应该设置为 0,0 并起作用。但是 IB 提供的主视图的原点设置为 0,20 并且呈灰色,因此我无法更改它。

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

深入查看笔尖支持的视图,它们看起来是一样的:settings nib backed

并且视图的布局就好像它是一个灰色状态栏,下降了 20 像素(在 IB 中它们被设置为黑色半透明,所以我将它们放置得高 20 像素)

除了应用程序 plist 条目之外,我还尝试以编程方式设置状态栏样式,但它没有效果(在任何这些选项卡上)。

我已经断断续续地研究这个问题(Google、stackoverflow、apple.com)几个星期了。但没有发现我应该做什么的迹象。

预计到达时间:wantsFullScreenLayout 解决了其中一个问题,因此我将其标记为已解决。我已经针对最初提出的两个问题之一提出了一个新问题,其中包含新的问题、新的图片、描述等以及更适用的标题,因为问题不是 uistatusbar 本身。新问题位于 新问题

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):
This is how it should look

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

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

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

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:
settings programmatically constructed

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

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

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

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

发布评论

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

评论(1

﹎☆浅夏丿初晴 2024-12-01 18:25:24

“我的理解是,设置此值后,所有视图的布局将从 0,0 开始,而不是像状态栏不透明时那样从 0,20 开始。”

你从哪里得到的?应用程序窗口的框架将保持原样,默认情况下位于 (0,0),并且它将保持在那里 - 它不关心状态栏的外观。

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

尝试将组成标签栏的每个视图控制器的 wantsFullScreenLayout 属性设置为 YES。它将根据您的需要将帧调至 (0,0)。

"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.

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