Member-only story

Pull To Refresh iOS Swift

Mr.Javed Multani
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:

--

--

Mr.Javed Multani
Mr.Javed Multani

Written by Mr.Javed Multani

Software Engineer | Certified ScrumMaster® (CSM) | UX Researcher | Youtuber | Tech Writer

No responses yet