7

I am trying to cover status bar with my own view and to do that I calculcate frame for my view by doing something like that (also after rotation):

UIScreen *screen = [UIScreen mainScreen];
CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;

For iOS8+ (because since ios8 UIScreen is orientantion-dependant):

CGRect frame = [screen.coordinateSpace convertRect:statusBarFrame toCoordinateSpace:screen.fixedCoordinateSpace];
[self setFrame:frame];

For iOS7:

[self setFrame:statusBarFrame];

It works just fine for iOS8 and below but when building my app with Xcode 7 beta 4 and iOS 9 SDK something is wrong when starting app in landscape or upsidedown (it works fine if app starts in portrait) ...

ie. when I start the app while Upsidedown the custom uiwindow which should cover status bar will always end up at the bottom side of screen, any ideas what might be wrong?

PinkeshGjr
  • 8,460
  • 5
  • 41
  • 56
Artrmz
  • 340
  • 2
  • 14
  • rushelmet, not yet :( – Artrmz Oct 21 '15 at 06:48
  • Check out the last answer: http://stackoverflow.com/questions/33244580/view-above-the-status-bar/33244933#33244933 – rushelmet Oct 21 '15 at 15:16
  • Well I see the reason to set a view above the status bar to use the space there without covering the whole status bar. But when you want to cover the whole status bar, why don't you simply hide the status bar and pin your own view at the top with simple constraints? – Axel Zehden Jun 03 '16 at 08:48

1 Answers1

0

Without additional information, the best solution would be to simply hide the status bar. If you still want the "status bar" for animation purposes or some other reason, the typical solution in this scenario is to simulate it by calling

- (UIView *)snapshotViewAfterScreenUpdates:(BOOL)afterUpdates on UIScreen

and use the returned view as the background for whatever view/window you're presenting. As of iOS 9, there's no public method that'll allow you to get the specific behavior you specified.

William LeGate
  • 540
  • 7
  • 18