title: Angled Gradient Layer
body: <p>I have custom <code>UIView</code> class that renders a gradient in Swift 2. I'm struggling with making an angled gradient so that it draws from the top-left to the bottom-right. Can somebody help me a bit?</p>
  
  <pre><code>import UIKit
  
  class GradientView: UIView {
  
      let gradientLayer = CAGradientLayer()
  
      override func awakeFromNib() {
          // 1
          self.backgroundColor = ColorPalette.White
  
          // 2
          gradientLayer.frame = self.bounds
  
          // 3
          let color1 = ColorPalette.GrdTop.CGColor as CGColorRef
          let color2 = ColorPalette.GrdBottom.CGColor as CGColorRef
          gradientLayer.colors = [color1, color2]
  
          // 4
          gradientLayer.locations = [0.0, 1.0]
  
          // 5
          self.layer.addSublayer(gradientLayer)
      }
  
  }
  </code></pre>
  
  <p>I suspect this should be something else but whatever I input nothing changes.</p>
  
  <pre><code>gradientLayer.locations = [0.0, 1.0]
  </code></pre>