Member-only story
Pull To Refresh iOS Swift
1 min readOct 3, 2020
You can achieve this by using few lines of code. So why you are going to stuck in third party library or UI.
Pull to refresh is built in iOS. You could do this in swift like
var refreshControl = UIRefreshControl()override func viewDidLoad() {
super.viewDidLoad() refreshControl.attributedTitle = NSAttributedString(string: "Pull to refresh")
refreshControl.addTarget(self, action: #selector(refresh(_:)), for: UIControl.Event.valueChanged)
tableView.addSubview(refreshControl) // not required when using UITableViewController
}@objc func refresh(sender:AnyObject) {
// Code to refresh table view
}
At some point you could end refreshing.
refreshControl.endRefreshing()
Result: