I have a UITableView within my UIViewController and have added a UIRefreshControl as so:
lazy var refreshControl: UIRefreshControl = {
let refreshControl = UIRefreshControl()
refreshControl.addTarget(self, action: #selector(ListViewController.handleRefresh), for: UIControlEvents.valueChanged)
return refreshControl
}()
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.addSubview(self.refreshControl)
}
It works fine but produces a nasty UI effect where it overlaps the header view.
I have tried setting the frame height
and contentInset
but neither worked.
What I discovered was that I had to put a delay on the UIRefreshControl dismissal for the UI to function properly.
This may be very unique to me but I am posting it just in case.
let when = DispatchTime.now() + 0.5 // change to desired number of seconds
DispatchQueue.main.asyncAfter(deadline: when) {
refreshControl.endRefreshing()
}