How to add refresh control to collection view large titles navigation bar in iOS 11?

Viewed 10840

According to Apple the refresh control should be part of the large title navigation bar in iOS 11.

The refresh control is part of the navigation bar (on pull to refresh) when I enabled the refresh control in my storyboard for a UITableViewController.

refresh control with large titles

I can not do this in storyboard for all other views like UICollectionViewController. When I add a refresh control in code as a subview it is not part of the navigation bar:

refreshControl = UIRefreshControl()
collectionView?.addSubview(refreshControl)

It looks like this though:

looks like this though

How can I add a refresh control to my custom scroll view like UICollectionViewController in such a way that the refresh control is displayed in the navigation bar when large titles is used?

3 Answers

In my case, I wanted to have UIView under UITableView, so UITableView wasn't first subview of view controller's view.

To fix this, I changed order of UITableView and other UIView

from

enter image description here

to

enter image description here

Now I just set zPosition of my view to lower value than UITableView's zPosition which should make my view look like it is "under" UITableView

myView.layer.zPosition = -1

Related