title: How do I change the z index or stack order of UIView?
body: <p>I've stacked a UIView on top of an existing controller in an effort to create a gradient layer. However, when I load the view the new UIView (naturally) is on top of everything. </p>
  
  <p>Relevant Code:</p>
  
  <pre><code>class ViewController: UIViewController {
  
      @IBOutlet weak var myGradientView: GradientView!
  
      override func viewDidLoad() {
          super.viewDidLoad()            
      }
  
      override func viewDidLayoutSubviews() {
          self.myGradientView.gradientWithColors(UIColor.whiteColor(), UIColor.blueColor())
      }
  }
  </code></pre>
  
  <p>I've done some searching and I found <a href="https://stackoverflow.com/questions/4631878/how-to-set-iphone-ui-view-z-index">an answer in Objective-C</a> that explains to use:</p>
  
  <blockquote>
    <p>[parentView bringSubviewToFront:view];</p>
  </blockquote>
  
  <p>I don't know objective-c and am fairly new to Swift, if someone could shine some light on this I would appreciate it. </p>
  
  <h2>My Question:</h2>
  
  <p>How do I change the z index or stack order of a UIView in Swift?</p>