artur-dev
artur-dev

Reputation: 350

iOS9 covering status bar with custom uiwindow - wrong position

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?

Upvotes: 8

Views: 852

Answers (1)

William LeGate
William LeGate

Reputation: 550

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.

Upvotes: 0

Related Questions