From 25dbc3dba419d595a250c60e3aff84d4518532fa Mon Sep 17 00:00:00 2001 From: Anton Schukin Date: Sat, 9 Nov 2019 13:05:24 +0000 Subject: [PATCH] Fixed an issue with wrong scroll indicator insets on iOS 13 --- .../ChatController/BaseChatViewController.swift | 7 ++++--- Chatto/Source/Utils.swift | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Chatto/Source/ChatController/BaseChatViewController.swift b/Chatto/Source/ChatController/BaseChatViewController.swift index 58cc46523..86db8d729 100644 --- a/Chatto/Source/ChatController/BaseChatViewController.swift +++ b/Chatto/Source/ChatController/BaseChatViewController.swift @@ -167,7 +167,8 @@ open class BaseChatViewController: UIViewController, UICollectionViewDataSource, collectionView.dataSource = self collectionView.delegate = self collectionView.chatto_setContentInsetAdjustment(enabled: false, in: self) - + collectionView.chatto_setAutomaticallyAdjustsScrollIndicatorInsets(false) + self.accessoryViewRevealer = AccessoryViewRevealer(collectionView: collectionView) self.collectionView = collectionView @@ -344,12 +345,12 @@ open class BaseChatViewController: UIViewController, UICollectionViewDataSource, return currentInsets }() - collectionView.scrollIndicatorInsets = { + collectionView.chatto_setVerticalScrollIndicatorInsets({ var currentInsets = collectionView.scrollIndicatorInsets currentInsets.bottom = self.layoutConfiguration.scrollIndicatorInsets.bottom + inputHeightWithKeyboard currentInsets.top = self.topLayoutGuide.length + self.layoutConfiguration.scrollIndicatorInsets.top return currentInsets - }() + }()) guard shouldUpdateContentOffset else { return } diff --git a/Chatto/Source/Utils.swift b/Chatto/Source/Utils.swift index c29126728..032364dbe 100644 --- a/Chatto/Source/Utils.swift +++ b/Chatto/Source/Utils.swift @@ -44,4 +44,18 @@ extension UIScrollView { viewController.automaticallyAdjustsScrollViewInsets = enabled #endif } + + func chatto_setAutomaticallyAdjustsScrollIndicatorInsets(_ adjusts: Bool) { + if #available(iOS 13.0, *) { + self.automaticallyAdjustsScrollIndicatorInsets = adjusts + } + } + + func chatto_setVerticalScrollIndicatorInsets(_ insets: UIEdgeInsets) { + if #available(iOS 11.1, *) { + self.verticalScrollIndicatorInsets = insets + } else { + self.scrollIndicatorInsets = insets + } + } }