title: Setting backgroundView of Tableview
body: <p>My problem is the layer hierarchy of "tableView.backgroundView".</p>
  
  <p>I wanted to implement a background image for my tableview and all works fine in a demo project.</p>
  
  <pre><code>var testImage = UIImage(named: "Test_Image")
  imageView.image = testImage
  mytableView.backgroundColor = UIColor.greenColor()
  mytableView.backgroundView = imageView
  </code></pre>
  
  <p>If i call this in the demo project (e.g. in the tableView Controller's viewDidLoad method) all works fine and the hierarchy is correct. All the buttons/labels/images... of the cell are loaded dynamically and they are all above the tableview's backgroundColor and backgroundView.</p>
  
  <p>I even looked it up with the UI View Hierarchy Manager in Debug modus and checked it.</p>
  
  <p>But in my real project, when the tableview did load, the backgroundView of the tableview is on the top of all views?</p>
  
  <p><strong>So how can it be that the tableview.backgroundView is on the top stack of the views? All the buttons/labels/images... of the cells are between the tableview itself and the tableview.backgroundView?</strong></p>
  
  <p>The question is actually a general one. I'm just wondering why the backgroundView of tableView can be in front of other views? Interestingly the tableview.backgroundcolor stays in the back.</p>
  
  <p>If you need more information please tell me. I will try to give as much information as possible.</p>
  
  <p><a href="https://i.stack.imgur.com/tilK8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tilK8.png" alt="View hierarchy"></a></p>
  
  <pre><code>@IBOutlet var mytableView: UITableView!
  
  var man = UIImage(named: "Timeline_Background_Man")
  var woman = UIImage(named: "Timeline_Background_Woman")
  var imageView = UIImageView()
  
  var delegate: CenterViewControllerDelegate?
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      imageView.image = man
      mytableView.backgroundColor = UIColor.greenColor()
      imageView.contentMode = .ScaleAspectFit
      mytableView.backgroundView = imageView
  }
  </code></pre>
  
  <p>Thanks in advance!</p>