title: Add layer underneath subviews
body: <p>I am trying to add a sublayer of the function <code>setupPlayerView</code> below subviews which have been loaded previously. The subviews are loaded faster than the layer as the function creating the layer uses a string which is modified from another class, a <code>UIViewController</code> (I want to load individual videos). I found an answer on stackoverflow but the suggested solution of <code>.insertSublayer(playerLayer, below: self.controlsContainerView.layer)</code> did not work for me. How can I ensure the videolayer is under all my other subviews like <code>controlsContainerView</code> and its subviews (e.g. <code>activityIndicatorView</code>) in turn?</p>
  
  <p>Here is what I got right now:</p>
  
  <pre><code>class PlayerView: UIView {
  
  var urlString: String? {
      didSet {
          setupPlayerView()
      }
  }
  
  override init(frame: CGRect){
  
      super.init(frame: frame)
  
      //although the function is called immediately it is not the "lower" than everything else
      setupPlayerView()
  
      //add subview with controls (e.g. spinner)
      controlsContainerView.frame = frame
      addSubview(controlsContainerView)
  
      //add to subview and center spinner in subview
      controlsContainerView.addSubview(activityIndicatorView) // (spinner)
      controlsContainerView.addSubview(whiteView)
  
      //...
  }
  
  //... irrelevant code (closures like `activityIndicatorView` and `whiteView`)
  
  //setup video player
  func setupPlayerView() {
  
      if let urlString = self.urlString, let videoURL = NSURL(string: urlString){
  
          print(urlString)
  
          //player's video
          if self.player == nil {
              player = AVPlayer(url: videoURL as URL)
          }
  
          //add sub-layer
          let playerLayer = AVPlayerLayer(player: player)
          playerLayer.frame = self.frame
          self.controlsContainerView.layer.insertSublayer(playerLayer, below: self.controlsContainerView.layer)
  
          //when are frames actually rendered (when is video loaded so one can remove spinner)
          player?.addObserver(self, forKeyPath: "currentItem.loadedTimeRanges", options: .new, context: nil)
  
      }
  
  }
  </code></pre>
  
  <p>For those interested: I change <code>urlString</code> the following way in another class (a ViewController):</p>
  
  <pre><code>videoPlayerView.urlString = videoUrl //videoUrl being some link to a video source
  </code></pre>