I am having some issues with my status bar. This is an iPhone app, not an iPad app. I would like 开发者_StackOverflow社区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.
精彩评论