After Setting Safe Area in iphone x . When Keyboard opens the safe area (The white area above keyboard ) comes above the keyboard so how to handle the keyboard ?
White Area above The Keyboard .
handle keyboard Code :-
func keyboardWillChangeFrameWithNotification(_ notification: Notification, showsKeyboard: Bool) {
let userInfo = notification.userInfo!
let animationDuration: TimeInterval = (userInfo[UIKeyboardAnimationDurationUserInfoKey] as! NSNumber).doubleValue
let keyboardScreenEndFrame = (userInfo[UIKeyboardFrameEndUserInfoKey] as! NSValue).cgRectValue
// keyboardRect = [self.view convertRect:keyboardRect fromView:nil];
let keyBoardRect = self.view.convert(keyboardScreenEndFrame, from:nil)
UIView.animate(withDuration: animationDuration, delay: 0, options: .beginFromCurrentState, animations: {
// Keyboard is going to appear. move composebar up
if showsKeyboard {
self.constraintBottomAttachmentView.constant = keyBoardRect.size.height
} else { // Keyboard is going to disappear. Move composebar down.
self.constraintBottomAttachmentView.constant = 0
}
self.view.layoutIfNeeded()
}, completion: { finished in
// Update the height of recipient bar.
self.updateRecipientBarMaxHeight()
})
}
keyboard height has increased in iphone x so if i subtract - 34 from keyboard height the white area decreases . Code:-
if showsKeyboard {
self.constraintBottomAttachmentView.constant = keyBoardRect.size.height - self.view.safeAreaInsets.bottom /*(34)*/ }
So how to solve this issue without manually doing this and in an optimised way ?