title: Fill a CAShapeLayer with Gradient in swift?
body: <p>I have filled the circle boundary with CAShapeLayer.Now i am giving my CAShape color as red but i want to give it as a gradient color.Please tell me how can i do this?</p>
  
  <pre><code>circlePath = UIBezierPath(arcCenter: centerPoint, radius: circleRadius, startAngle: CGFloat(1.5 * M_PI), endAngle: CGFloat(-0.5 * M_PI), clockwise: false)
  
  
          //add gradient to the below
          progressCircle = CAShapeLayer ()
          progressCircle.path = circlePath?.cgPath
          progressCircle.strokeColor = UIColor.red.cgColor
          progressCircle.fillColor = UIColor.clear.cgColor
          progressCircle.lineWidth = 4.0
          progressCircle.strokeStart = 0
          progressCircle.strokeEnd = 0.7
  
          let gradient: CAGradientLayer = CAGradientLayer()
          let startingColorOfGradient = UIColor(colorLiteralRed: 50/255, green: 189/255, blue: 170/255, alpha: 1.0).cgColor
          let endingColorOFGradient = UIColor(colorLiteralRed: 133/255, green: 210/255, blue: 230/255, alpha: 1.0).cgColor
          gradient.startPoint = CGPoint(x: 1.0, y: 0.5)
          gradient.endPoint = CGPoint(x: 0.0, y: 0.5)
          gradient.colors = [startingColorOfGradient , endingColorOFGradient]
  
          circle.layer.addSublayer(progressCircle)
  circle.layer.addSublayer(gradient)
  </code></pre>