Try the following:
extension UIRefreshControl {
func refreshManually() {
beginRefreshing()
sendActions(for: .valueChanged)
}
}
var isRefreshingManually = false
func scrollViewDidScroll(_ scrollView: UIScrollView) {
if scrollView.contentOffset.y < -80.0 {
if !isRefreshingManually && !refreshControl.isRefreshing {
isRefreshingManually = true
refreshControl.refreshManually()
}
} else if scrollView.contentOffset.y >= 0 {
isRefreshingManually = false
}
}
My sample code is for UICollectionView, but UITableView and UIScollView work too.
Replace "-80.0" in my code with what you need.
source
share