3

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

Community
  • 1
  • 1
chadbag
  • 1,837
  • 2
  • 20
  • 34

1 Answers1

4

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

MiguelB
  • 1,913
  • 18
  • 20
  • ok, thanks. I don't know where I got it from (mistaken belief you quoted). Probably misremembered something I had read mixed together with observed behaviors and came to a wrong conclusion. – chadbag Jul 18 '11 at 20:52
  • However, I still have the same problem. The MainWindow.xib has a tab bar controller in it with 5 navigation controllers as tabs. Each of those I set to wantsFullScreenLayout in IB. Each of those has a view controller and I also set wantsFullScreenLayout for each of those in IB. I set my background image in each viewcontroller to be 0,0 320w 480h. The first tab still looks correct, other have nada under statusbar so it all still looks the same under the statusbar -- translucent black over white and not my background. (The various views contents did shift up 20 pix as expected) – chadbag Jul 18 '11 at 20:59
  • btw, my second problem with the settings tab was fixed 100% with the wantsFullScreenLayout. Done programatically at each pushViewController: Thanks! – chadbag Jul 18 '11 at 22:15
  • Still struggling with this. I did update every controller with wantsFullScreenLayout in IB (the tab bar controller, each navigation controller in the tab bar controller, and each root view controller in each navigation controller). This did solve the problem (along with doing it programatically for pushed VC) for the last tab, the one that I refer to as settings above. However, the other tabs are still the same issue (after I corrected all the images origins to 0,0 instead of 0,-20). The first one is correct and the other 3 have the view background "clipped" to be below the statusbar. – chadbag Jul 21 '11 at 16:02
  • You really need to show some code. I'm afraid the extent of my help is limited otherwise. – MiguelB Jul 21 '11 at 17:24
  • What code do you want to see? It is all in the nib. There is no code that is doing anything layout-wise. In the app delegate, I put `[[self window] setRootViewController:[self tabBarController]];` (yes I am old school) with the tab bar controller being in MainWindow.xib. None of the VC have any layout code in the their `viewDidLoad` or `viewWillAppear:` . That is why I am stumped – chadbag Jul 21 '11 at 19:11
  • Since the question has changed and this question was partially answered (the `wantsFullScreenLayout` was correct answer and was needed and solved the problem on one tab) I have created a new question with more info and pictures, a new and better description since this one was mistaken in some assumptions and description, and part of this was correctly answered. – chadbag Jul 21 '11 at 20:29