But if the keyboard dismisses, the top Windows will be removed, so your customView will be removed.
Looking forward for your help!
Thank you for your help!
The trick is to add the customView as a top subview to the UIWindow that holds the keyboard - and it happens to be the last window in UIApplication.shared.windows.
While this can be possible with accessing the topmost window, I would avoid doing this, as it clearly interferes with Apple's guidelines.
What I would do is dismissing the keyboard and replacing its frame with a view with same dimensions.
The keyboard's frame can be accessed from keyboard notifications listed here, their userInfo contain a key that can be accessed with UIKeyboardFrameEndUserInfoKey.
You can definitely add the view to your application’s window, and you can also add another window entirely. You can set its frame and level. The level could be UIWindowLevelAlert.
Do you have find some effective method to solve this problem? In iOS9,you put your customView on the top of the windows:
But if the keyboard dismisses, the top Windows will be removed, so your
customView
will be removed. Looking forward for your help! Thank you for your help!Swift 4 version:
The trick is to add the
customView
as a top subview to theUIWindow
that holds the keyboard - and it happens to be the last window inUIApplication.shared.windows
.Swift 4.0
While this can be possible with accessing the topmost window, I would avoid doing this, as it clearly interferes with Apple's guidelines.
What I would do is dismissing the keyboard and replacing its frame with a view with same dimensions.
The keyboard's frame can be accessed from keyboard notifications listed here, their
userInfo
contain a key that can be accessed withUIKeyboardFrameEndUserInfoKey
.You can add that new subview to your application window.
You can definitely add the view to your application’s window, and you can also add another window entirely. You can set its frame and level. The level could be
UIWindowLevelAlert
.