diff --git a/lib/ObservingInputAccessoryView.m b/lib/ObservingInputAccessoryView.m index e472679..b1c2682 100644 --- a/lib/ObservingInputAccessoryView.m +++ b/lib/ObservingInputAccessoryView.m @@ -85,10 +85,16 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N centerY = [change[NSKeyValueChangeNewKey] CGPointValue].y; } + CGFloat bottomPadding = 0; CGFloat boundsH = self.superview.bounds.size.height; + if (@available(iOS 11.0, *)) { + UIWindow *window = UIApplication.sharedApplication.keyWindow; + bottomPadding = window.safeAreaInsets.bottom; + } + _previousKeyboardHeight = _keyboardHeight; - _keyboardHeight = MAX(0, self.window.bounds.size.height - (centerY - boundsH / 2) - self.intrinsicContentSize.height); + _keyboardHeight = MAX(0, self.window.bounds.size.height - (centerY - boundsH / 2) - self.intrinsicContentSize.height - bottomPadding); [_delegate observingInputAccessoryViewDidChangeFrame:self]; }