window level on iOS11

// FREEBIE
pull/1/head
Michael Kirk 7 years ago
parent d31b91663c
commit 3a157d9df6

@ -55,9 +55,27 @@ const UIWindowLevel UIWindowLevel_MessageActions(void)
{ {
// Note: To cover the keyboard, this is higher than the ScreenBlocking level, // Note: To cover the keyboard, this is higher than the ScreenBlocking level,
// but this window is hidden when screen protection is shown. // but this window is hidden when screen protection is shown.
return CGFLOAT_MAX - 100; return CGFLOAT_MAX;
} }
@interface MessageActionsWindow : UIWindow
@end
@implementation MessageActionsWindow
- (UIWindowLevel)windowLevel
{
// As of iOS11, setWindowLevel clamps the value below
// the height of the keyboard window.
// Because we want to display above the keyboard, we hardcode
// the `windowLevel` getter.
return UIWindowLevel_MessageActions();
}
@end
@implementation OWSWindowRootViewController @implementation OWSWindowRootViewController
- (BOOL)canBecomeFirstResponder - (BOOL)canBecomeFirstResponder
@ -184,14 +202,21 @@ const UIWindowLevel UIWindowLevel_MessageActions(void)
- (UIWindow *)createMessageActionsWindowWithRoowWindow:(UIWindow *)rootWindow - (UIWindow *)createMessageActionsWindowWithRoowWindow:(UIWindow *)rootWindow
{ {
UIWindow *window = [[UIWindow alloc] initWithFrame:rootWindow.bounds]; UIWindow *window;
window.hidden = YES; if (@available(iOS 11, *)) {
// On iOS11, setting the windowLevel is insufficient, so we override
// the `windowLevel` getter.
window = [[MessageActionsWindow alloc] initWithFrame:rootWindow.bounds];
} else {
// On iOS9, 10 overriding the `windowLevel` getter does not cause the
// window to be displayed above the keyboard, but setting the window
// level works.
window = [[UIWindow alloc] initWithFrame:rootWindow.bounds];
window.windowLevel = UIWindowLevel_MessageActions(); window.windowLevel = UIWindowLevel_MessageActions();
// window.opaque = YES; }
window.backgroundColor = UIColor.clearColor;
// window.rootViewController = navigationController; window.hidden = YES;
window.backgroundColor = UIColor.clearColor;
return window; return window;
} }

Loading…
Cancel
Save