title: I'd like to create a CAGradientLayer Subclass/Utility class
body: <p>I've been programming in one way or another for 30+ years, but I'm new to Swift and iOS programming and working on my first app. I've worked out how to create a CAGradientLayer to show a gradient on screen, but I'd like to create a utility class/extension/subclass with some predefined gradients in it.</p>
  
  <p>I am assuming I can do this by creating subclasses of CAGradientLayer with the properties pre-set at initialisation time, but I'm not sure of the correct syntax to do this. I guess I am missing some basic Swift requirements?</p>
  
  <p>I've tried the following:</p>
  
  <pre><code>let greenBlueGradient = GreenBlueGradient.greenBlueGradient()
  
  class GreenBlueGradient: CAGradientLayer {
  
      override init() {
          super.init()
      }
  
      func greenBlueGradient() -&gt; GreenBlueGradient {
          self.colors = [ UIColor.init( red: 0.05, green: 0.75, blue: 0.91, alpha: 1.0 ).CGColor, UIColor.init( red: 0.56, green: 0.93, blue: 0.56, alpha: 1.0 ).CGColor ]
          return self
      }
  
      required init?(coder aDecoder: NSCoder) {
          super.init(coder: aDecoder)
      }
  }
  </code></pre>
  
  <p>But I'm getting the error "Missing argument for parameter #1 in call" on the let line. What am I missing? Surely there is a more efficient way of doing this? I sort of have in my head that I will be able to create some sort of utility class/extension that will return a CAGradientLayer with the colors already set ready for me to set the frame and insert it into my view hierarchy.</p>