После установки безопасной зоны в iphone x. Когда клавиатура открывает безопасную область (белая область над клавиатурой), появляется над клавиатурой, так как обращаться с клавиатурой?
Белая область над клавиатурой.
Код ручки клавиатуры: -
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()
})
}
высота клавиатуры увеличилась в iphone x, поэтому, если я вычту -34 из высоты клавиатуры, белая область уменьшится. Код:-
if showsKeyboard {
self.constraintBottomAttachmentView.constant = keyBoardRect.size.height - self.view.safeAreaInsets.bottom /*(34)*/ }
Итак, как решить эту проблему, не делая этого вручную и оптимизированным способом?