UIRefreshControl and UITableView's backgroundVIew UIRefreshControl and UITableView's backgroundVIew ios ios

UIRefreshControl and UITableView's backgroundVIew


The reason for this behavior is that in iOS 7, the UITableView's backgroundView is drawn above the UIRefreshControl. Not sure if this is by design or an issue, but here is a workaround that fixed it for me :

   self.tableView.backgroundView.layer.zPosition -= 1;

This code goes where you set up your UITableViewController refreshControl property.


You could try sending the background to the back or the refresh control to the front. The refresh control is more than likely just sitting at index 0.


It seems that UITableViewController pushes its UIRefreshControl to back to the 0 index during reload (behind its "backgroundView"), regardless at what index you put it in the first place. This is what worked for me (iOS 9): Disable refreshing in IB. Create UIRefreshControl in code and add it to tableView after setting up backgroundView:

    let someView = UIView()    self.tableView.backgroundView = someView    let refreshControl = UIRefreshControl()    refreshControl.addTarget(self, action: #selector(MyTableViewController.refresh(_:)), forControlEvents: .ValueChanged)    self.tableView.insertSubview(refreshControl, atIndex: 1)