Couple of tips how to improve user experience with UIRefreshControl

Hello there. Reservation, next we’ll talk about embedding UIRefreshControl to UIScrollView, not to UINaviagtionBar, because in the second case all problems described below are absent.

Sometimes when you use refresh control you have noticed that a little scroll lag takes place. And for some reason refresh control animation proceed above content of scroll view.

Refresh control animation above content and jerking scroll animation

This post about how to configure UIRefreshControl to perform animation below content and without scroll lag.

The solution is quite simple. If backgrounColor of refresh control is set:

let refresh = UIRefreshControl()
refresh.backgroundColor = .systemBackground

then when the UIScrollVIew returns to its original position (content offset equals 0), the refresh control animation is performed below UIScrollView content.

There is the problem is also solved simply. Not worth it to add refresh control as:

let tableView = UITableView()
tableView.refreshControl = refreshControl

Although Apple’s developer documentation describes just such approach:

It’s necessary to add refresh control as subview:

let tableView = UITableView()

In this case, when the selector is triggered, there is no content jerking (scroll animation lag) and the animation looks much better.

These tips apply to both UITableView and UICollectionView, since they are inheritors of UIScrollView. That’s it. Good day for you.