i have a scrollview and am trying to scroll to its bottom programmatically..
tried these:
extension UIScrollView {
// Bonus: Scroll to bottom
func scrollToBottom() {
let bottomOffset = CGPoint(x: 0, y: contentSize.height - bounds.size.height + contentInset.bottom)
if(bottomOffset.y > 0) {
setContentOffset(bottomOffset, animated: true)
}
}
}
from:
Programmatically scroll a UIScrollView to the top of a child UIView (subview) in Swift
let bottomOffset = CGPoint(x: 0, y: scrollView.contentSize.height - scrollView.bounds.size.height)
scrollView.setContentOffset(bottomOffset, animated: true)
from:
UIScrollView scroll to bottom programmatically
but both didn't do anything ...
how to do it?