mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-28 23:32:41 +00:00
Add a method to UIScrollView
to scroll to bottom
This commit is contained in:
parent
3fd70eb186
commit
c14acb8889
1 changed files with 13 additions and 0 deletions
|
@ -30,5 +30,18 @@ extension UIScrollView {
|
|||
self.scrollRectToVisible(rect, animated: animated)
|
||||
}
|
||||
}
|
||||
|
||||
/// Scroll to bottom of the receiver.guard let self = self else { return }
|
||||
/// - Parameter animated: animate the scroll
|
||||
@objc func vc_scrollToBottom(animated: Bool = true) {
|
||||
guard contentSize.height >= bounds.height else {
|
||||
return
|
||||
}
|
||||
let bottomOffset = CGPoint(x: 0, y: contentSize.height - bounds.height + contentInset.bottom)
|
||||
if contentOffset != bottomOffset {
|
||||
// scroll only if not already there
|
||||
setContentOffset(bottomOffset, animated: animated)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue