Add activity indicator to the top of UITableView
Jan 11, 2022
In this short article we will see how to add activity indicator on top of UITableView.
For that, you have to create one tableView programmatically or using storyboard.
Step 1: Create one refresh control
// creating UIRefreshControl
lazy var refreshControl: UIRefreshControl = {let refreshControl = UIRefreshControl()// Add target for UIRefreshControlrefreshControl.addTarget(self, action: #selector(handleRefresh(_:)), for: UIControl.Event.valueChanged)// set tintColor for UIRefreshControlrefreshControl.tintColor = UIColor.greenreturn refreshControl}()@objc func handleRefresh(_ refreshControl: UIRefreshControl) {// do your refreshing partrefreshControl.endRefreshing()}
Step 2: Add UIRefreshControl in tableview
myTableView.addSubview(refreshControl)
Done๐๐๐
Hope you enjoyed reading this post!!
If you have any comment, question, or recommendation, feel free to post them in the comment section below!
Thank you!!! Happy coding.