I had a tableview which contentInset top is 44. When I has only one cell, I scroll up to refresh.
After stop, the contentOffset become 0, which should be minus contentInset.y
if scrollView.isDecelerating {
var contentOffset = scrollView.contentOffset
contentOffset.y = min(contentOffset.y, scrollView.contentSize.height - scrollView.frame.size.height)
// should be -scrollView.contentInset.top??
if contentOffset.y < 0.0 {
contentOffset.y = 0.0
UIView.animate(withDuration: 0.1, animations: {
scrollView.setContentOffset(contentOffset, animated: false)
})
} else {
scrollView.setContentOffset(contentOffset, animated: false)
}
}
I had a tableview which contentInset top is 44. When I has only one cell, I scroll up to refresh. After stop, the contentOffset become 0, which should be minus contentInset.y