iOS9 covering status bar with custom uiwindow - wrong position
Asked Answered
D

1

8

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?

Dichlorodifluoromethane answered 23/7, 2015 at 8:5 Comment(3)
rushelmet, not yet :(Dichlorodifluoromethane
Check out the last answer: https://mcmap.net/q/1474419/-view-above-the-status-bar/…Gamine
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?Complicate
M
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.

Moron answered 4/8, 2016 at 2:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.