I have a textView , and it's text content will increase . I want to know how to set a bool value , like isTextViewScrollToBottom:Bool when textView is scroll to bottom, then isTextViewScrollToBottom = true when textView is leave bottom, then isTextViewScrollToBottom = false
now, I only know can use scrollViewDelegate func like:
scrollViewDidEndDecelerating(_ scrollView: UIScrollView),
scrollViewWillBeginDragging(_ scrollView: UIScrollView),
scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool)
and I try this:
func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
checkIsScrollToBottom(scrollView)
}
func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
checkIsScrollToBottom(scrollView)
}
func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
checkIsScrollToBottom(scrollView)
}
fileprivate func checkIsScrollToBottom(_ scrollView: UIScrollView){
if textViewForChatContent.contentSize.height - scrollView.contentOffset.y == 301 {
isScrollToBottom = true
print("isScrollToBottom=\(isScrollToBottom)")
}else{
isScrollToBottom = false
print("isScrollToBottom=\(isScrollToBottom)")
}
}
but this Judgment is not good use for all device. is someone know better Judgment, can know textView is scroll to bottom?
thanks!