         RunLoop.main.add(timer, forMode: RunLoop.Mode.common)
         RunLoop.main.add(timer, forMode: RunLoop.Mode.tracking)
         self.timer = timer
+    }
+    
+    //From https://stackoverflow.com/a/39779603
+    private func blend(from: UIColor, to: UIColor, percent: Double) -> UIColor {
+        var fR : CGFloat = 0.0
+        var fG : CGFloat = 0.0
+        var fB : CGFloat = 0.0
+        var tR : CGFloat = 0.0
+        var tG : CGFloat = 0.0
+        var tB : CGFloat = 0.0
+        
+        from.getRed(&fR, green: &fG, blue: &fB, alpha: nil)
+        to.getRed(&tR, green: &tG, blue: &tB, alpha: nil)
+        
+        let dR = tR - fR
+        let dG = tG - fG
+        let dB = tB - fB
+        
+        let rR = fR + dR * CGFloat(percent)
+        let rG = fG + dG * CGFloat(percent)
+        let rB = fB + dB * CGFloat(percent)
+        
+        return UIColor(red: rR, green: rG, blue: rB, alpha: 1.0)
     }
 
     @objc

    /** Starts the incrementation fromValue to toValue */
    public func increment(fromValue: Double, toValue: Double, duration: Double = 0.3, completion: Completion? = nil) {
        self.completion = completion
        startIncrementation(fromValue: fromValue, toValue: toValue, duration: duration)
    }


                text = String(format: format, currentValue)
            }
        }
        //Update the color
        if startColor != nil && endColor != nil{
            textColor = blend(from: startColor!, to: endColor!, percent: progress / duration)
        }
    }

}
