0

I would like my status bar to be black and be 25% transparent. I understand that the status bar is transparent by default, and therefore takes on the color of the background. However when I set the views backgroundColor:

self.view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:.75f];

The status bar is completely black.

I have a toolbar which I set to black with an alpha of .75 and I am just trying to get them to match:

self.toolBar.tintColor = [UIColor whiteColor];
self.toolBar.barTintColor = [UIColor blackColor];
self.toolBar.alpha = .75f;

Any reason why the background color on the UIView is not respecting the alpha component?

enter image description here

EDIT:

Based on comment that view does not underlap the status bar. If I set background to green it shows that it works:

enter image description here

However if I start to add transparency to the green color, it does not get lighter it gets darker. Seems like the default is to be black underneath my only UIView, not white.

self.view.backgroundColor = [[UIColor greenColor] colorWithAlphaComponent:.25];

enter image description here

lostintranslation
  • 23,756
  • 50
  • 159
  • 262

1 Answers1

1

The status bar in iOS 7 is completely transparent. The problem may be that your view and the toolbar are not correctly underlapping the status bar. So you are seeing the black window behind it. (Or, in fact, you may setting the size of the window incorrectly, in which case you are seeing nothing at all behind the status bar.)

If the view does underlap the status bar, then you need to set the bar positioning of the toolbar to Top Attached so that its height increases up underneath the status bar. We should not be seeing a separate color for the status bar; it should appear to overlay your interface, lying in front of the top of the toolbar.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • I explain about bar positioning for top bar here: http://stackoverflow.com/a/22232805/341994 That answer is about a navigation bar but it's exactly parallel for a top toolbar on iPad. – matt Sep 09 '14 at 15:53
  • I don't understand what you mean. If I set the background color of my view to green the status bar is green. However for some reason there is black under that green. So if I set it to green with alpha of .25 its a dark green as black is showing through. Even if I get rid of the toolbar and just go with a blank view that fills the entire screen I cannot get black with .75 transparency. – lostintranslation Sep 09 '14 at 16:01
  • I already told you why. It's because the window is black behind it. Green with alpha of .25 over black is dark green. - However, my answer is still right. If your view is in fact underlapping the status bar, then it should _look_ like it. You should NOT have a separate status bar color; the _toolbar_ should underlap the status bar, and I have already explained to you how to do that. Your second and third screen shots are _wrong_. Concentrate on fixing the toolbar height and all will be well. – matt Sep 09 '14 at 16:52