← Back to list

Add activity indicator to the top of UITableView

In this short article we will see how to add activity indicator on top of UITableView.

Nitish Kumar · 2022-01-11 08:46 · 16 claps · 0.7 min read
#swift #uitableview #ios #activity-indicator #ios-app-development
Open on Medium ↗
Wiki topics: 📱 · Mobile Development

Add activity indicator to the top of UITableView

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 UIRefreshControl
refreshControl.addTarget(self, action: #selector(handleRefresh(_:)), for: UIControl.Event.valueChanged)
// set tintColor for UIRefreshControl
refreshControl.tintColor = UIColor.green
return refreshControl
}()
@objc func handleRefresh(_ refreshControl: UIRefreshControl) {
// do your refreshing part
refreshControl.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.


메타데이터
post_id
edf21ca0fffc
slug
add-activity-indicator-to-the-top-of-uitableview-edf21ca0fffc
url
https://medium.com/@nitishrajput912/add-activity-indicator-to-the-top-of-uitableview-edf21ca0fffc
canonical_url
https://medium.com/@nitishrajput912/add-activity-indicator-to-the-top-of-uitableview-edf21ca0fffc
author_url
https://medium.com/@nitishrajput912
status
ok
fetched_at
2026-08-04 14:06:59