From fdad96f990534894499c840310033d8b75a774b9 Mon Sep 17 00:00:00 2001 From: Suyeol Jeon Date: Sun, 10 Jun 2018 14:39:35 -0700 Subject: [PATCH] Fix example project bottom margin --- .../RxKeyboardExample.xcodeproj/project.pbxproj | 4 ++-- .../MessageListViewController.swift | 17 ++++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Example/RxKeyboardExample.xcodeproj/project.pbxproj b/Example/RxKeyboardExample.xcodeproj/project.pbxproj index 8a760b8..d93cb20 100644 --- a/Example/RxKeyboardExample.xcodeproj/project.pbxproj +++ b/Example/RxKeyboardExample.xcodeproj/project.pbxproj @@ -340,7 +340,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 10.2; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -392,7 +392,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 10.2; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; diff --git a/Example/Sources/ViewControllers/MessageListViewController.swift b/Example/Sources/ViewControllers/MessageListViewController.swift index c3b2e6e..be904ec 100644 --- a/Example/Sources/ViewControllers/MessageListViewController.swift +++ b/Example/Sources/ViewControllers/MessageListViewController.swift @@ -92,13 +92,12 @@ class MessageListViewController: UIViewController { RxKeyboard.instance.visibleHeight .drive(onNext: { [weak self] keyboardVisibleHeight in guard let `self` = self, self.didSetupViewConstraints else { return } - var actualKeyboardHeight = keyboardVisibleHeight - if #available(iOS 11.0, *), keyboardVisibleHeight > 0 { - actualKeyboardHeight = actualKeyboardHeight - self.view.safeAreaInsets.bottom - } - self.messageInputBar.snp.updateConstraints { make in - make.bottom.equalTo(self.bottomLayoutGuide.snp.top).offset(-actualKeyboardHeight) + if #available(iOS 11.0, *) { + make.bottom.equalTo(self.view.safeAreaLayoutGuide.snp.bottom).offset(-keyboardVisibleHeight) + } else { + make.bottom.equalTo(self.bottomLayoutGuide.snp.top).offset(-keyboardVisibleHeight) + } } self.view.setNeedsLayout() UIView.animate(withDuration: 0) { @@ -140,7 +139,11 @@ class MessageListViewController: UIViewController { } self.messageInputBar.snp.makeConstraints { make in make.left.right.equalTo(0) - make.bottom.equalTo(self.bottomLayoutGuide.snp.top) + if #available(iOS 11.0, *) { + make.bottom.equalTo(self.view.safeAreaLayoutGuide.snp.bottom) + } else { + make.bottom.equalTo(self.bottomLayoutGuide.snp.top) + } } }