[Added] additionalTopContentInset property

This commit is contained in:
Steven Deutsch
2017-10-03 03:43:29 -05:00
parent ea00a643ca
commit e8ea04496d
2 changed files with 11 additions and 0 deletions
+3
View File
@@ -26,6 +26,9 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/Messa
- `scrollsToBottomOnFirstLayout` property to automatically scroll to the bottom of `MessagesCollectionView` on first load.
[#213](https://github.com/MessageKit/MessageKit/pull/213) by [@FraDeliro](https://github.com/FraDeliro).
- `additionalTopContentInset` property to `MessagesColectionViewController` to allow users to account for extra subviews.
[#218](https://github.com/MessageKit/MessageKit/pull/218) by [@SD10](https://github.com/SD10).
### Fixed
- `MessageInputBar` now correctly sizes itself when breaking its max height or pasting in large amounts of text
+8
View File
@@ -34,6 +34,13 @@ open class MessagesViewController: UIViewController {
open var scrollsToBottomOnFirstLayout: Bool = false
open var additionalTopContentInset: CGFloat = 0 {
didSet {
let inset = topLayoutGuide.length + additionalTopContentInset
messagesCollectionView.contentInset.top = inset
}
}
private var isFirstLayout: Bool = true
open override var canBecomeFirstResponder: Bool {
@@ -69,6 +76,7 @@ open class MessagesViewController: UIViewController {
// Hack to prevent animation of the contentInset after viewDidAppear
if isFirstLayout {
addKeyboardObservers()
messagesCollectionView.contentInset.top = additionalTopContentInset + topLayoutGuide.length
messagesCollectionView.contentInset.bottom = messageInputBar.frame.height
messagesCollectionView.scrollIndicatorInsets.bottom = messageInputBar.frame.height
isFirstLayout = false