I have a UICollectionView
with the regular pull to refresh implementation, but somehow the spinner and the "pull to refresh" text appear above the collection view items;
How can I make it behind the items?
This is how I add the UIRefreshControll
to the UICollectionView
let refreshControl = UIRefreshControl()
refreshControl.attributedTitle = NSAttributedString(string: "Pull down to refresh")
refreshControl.addTarget(self, action: #selector(pullToRefresh), for: UIControlEvents.valueChanged)
collectionView?.refreshControl = refreshControl
You can add a refresh control to a table or collection view by assigning an instance of the UIRefreshControl class to this property. If your application targets versions prior to iOS 10, you simply add the refresh control as a subview to the table view.
Overview. A UIRefreshControl object is a standard control that you attach to any UIScrollView object, including table views and collection views. Add this control to scrollable views to give your users a standard way to refresh their contents.
The way I figure this out is to change the refreshControll
zPosition
to be behind every view with the following:
refreshControl.layer.zPosition = -1
Hope this helps anyone further.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With