title: What's the equivalent of CAGradientLayer in swift?
body: <p>I'm trying to port over some objective-C code that creates a gradient layer</p>
  
  <pre><code>CAGradientLayer *gradientLayer = [CAGradientLayer layer];
  gradientLayer.colors = colors;
  gradientLayer.locations = locations;
  gradientLayer.frame = view.bounds;
  
  [view.layer insertSublayer:gradientLayer atIndex:index];
  </code></pre>
  
  <p>However in Swift, CAGradientLayer does not seem to have a static 'layer' method or a constructor. Trying to use it as a type produces:</p>
  
  <pre><code>let a:CAGradientLayer? = null
  </code></pre>
  
  <blockquote>
    <p>Error: Use of module 'CAGradientLayer' as a type</p>
  </blockquote>
  
  <p>As far as I can tell, CAGradientLayer is not a module I can import. What's the correct way of doing a gradient layer in Swift?</p>