     var toRads: CGFloat { return self * CGFloat(M_PI) / 180 }
 }
 
+extension UILabel {
+    func update(withValue value: CGFloat, valueIndicator: String, showsDecimal: Bool, decimalPlaces: Int) {
+        if showsDecimal {
+            self.text = String(format: "%.\(decimalPlaces)f", value) + "\(valueIndicator)"
+        } else {
+            self.text = "\(Int(value))\(valueIndicator)"
+        }
+        self.sizeToFit()
+    }
+}
+
 @IBDesignable
-public class UICircularProgressRingView: UIView {
+public class UICircularProgressRingView: UIView, CAAnimationDelegate {
     
     // MARK: Value properties
     
     /// The value of the current progress. Range [0, maxValue]
     @IBInspectable public var value: CGFloat = 0 {
-        didSet {
-            self.setNeedsDisplay()
-        }
-    }
+        willSet {
+            print("========== OLD \(self.value)")
+            self.oldValue = self.value
+        }
+        didSet {
+            self.setNeedsDisplay()
+        }
+    }
+    
+    private var oldValue: CGFloat = 0.0
+    
     /// The value of the maximum amount of progress. Range [0, ∞]
     @IBInspectable public var maxValue: CGFloat = 100 {
         didSet {

            self.setNeedsDisplay()
        }
    }
    
    public var animationDuration: CFTimeInterval = 1.0
    public var animationStyle: String = kCAMediaTimingFunctionEaseIn
    
    private lazy var shapeLayer = CAShapeLayer()
    
    
    // MARK: Methods

        self.addSubview(valueLabel)
    }
    
    public func setValue(_ newVal: CGFloat, animated: Bool, completion: () -> Void) {
        self.value = newVal
        if animated {
            animateInnerRing()
        }
        
    }
    
    private lazy var startTime = CACurrentMediaTime()
    private lazy var link = CADisplayLink()
    
    func animateInnerRing() {
        let animation = CABasicAnimation(keyPath: "strokeEnd")
