         dashCircleLayer.strokeStart = 0
         dashCircleLayer.strokeEnd   = 1
         
-        dashCircleLayer.backgroundColor = UIColor.redColor().CGColor
+    }
+    
+    // MARK: - 设置渐变颜色层
+    
+    private func setup02() {
         
-        view.layer.addSublayer(dashCircleLayer)
+        // 创建渐变图层
+        faucet = CAGradientLayer()
+        faucet.frame = CGRectMake(0, 0, radius*2, radius*2)
+        faucet.position = CGPointMake(CGRectGetWidth(view.bounds)/2, radius + 36)
+        
+        // 以CAShapeLayer的形状作为遮罩是实现特定颜色渐变的关键
+        faucet.mask = dashCircleLayer
+        faucet.colors = [
+            UIColor.greenColor().CGColor,
+            UIColor.redColor().CGColor,
+            UIColor.cyanColor().CGColor,
+            UIColor.purpleColor().CGColor,
+            UIColor.yellowColor().CGColor
+        ]
+        
+        // 设定动画时间
+        faucet.speed = 0.5
+        
+        // 添加到系统图层中
+        view.layer.addSublayer(faucet)
+        
     }
 
 }

class ViewController02: UIViewController {

    private var dashCircleLayer : CAShapeLayer!     // 虚线圆环
    
    // MARK: -
    

        
        // 设置虚线圆环
        setup01()
        
        // 设置渐变层
        setup02()
    }
    
    func timerEvent() {
        
        faucet.colors = [
            UIColor(red: CGFloat(arc4random() % 255)/255, green: CGFloat(arc4random() % 255)/255, blue: CGFloat(arc4random() % 255)/255, alpha: 1).CGColor,
            UIColor(red: CGFloat(arc4random() % 255)/255, green: CGFloat(arc4random() % 255)/255, blue: CGFloat(arc4random() % 255)/255, alpha: 1).CGColor,
            UIColor(red: CGFloat(arc4random() % 255)/255, green: CGFloat(arc4random() % 255)/255, blue: CGFloat(arc4random() % 255)/255, alpha: 1).CGColor,
            UIColor(red: CGFloat(arc4random() % 255)/255, green: CGFloat(arc4random() % 255)/255, blue: CGFloat(arc4random() % 255)/255, alpha: 1).CGColor,
            UIColor(red: CGFloat(arc4random() % 255)/255, green: CGFloat(arc4random() % 255)/255, blue: CGFloat(arc4random() % 255)/255, alpha: 1).CGColor]
    }
    
    // MARK: - 设置虚线圆环
