 class CustomInfiniteIndicator: UIView {
     
     var thickness: CGFloat = 2
-    var outerColor = UIColor.grayColor().colorWithAlphaComponent(0.2)
+    var outerColor = UIColor.gray.withAlphaComponent(0.2)
     
     lazy var innerColor: UIColor = {
         return self.tintColor
     }()
-
+    
     private var animating = false
     private let innerCircle = CAShapeLayer()
     private let outerCircle = CAShapeLayer()

        let anim = animation()
        anim.timeOffset = stopTime - startTime
        
        layer.addAnimation(anim, forKey: rotationAnimationKey)
        
        startTime = layer.convertTime(CACurrentMediaTime(), fromLayer: nil)
    }
    
    private func removeAnimation() {
        layer.removeAnimationForKey(rotationAnimationKey)
        
        stopTime = layer.convertTime(CACurrentMediaTime(), fromLayer: nil)
    }
    
    func restartAnimationIfNeeded() {
        let anim = layer.animationForKey(rotationAnimationKey)
        
        if animating && anim == nil {
            removeAnimation()

    }
    
    private func registerForAppStateNotifications() {
        NotificationCenter.default.addObserver(self, selector: #selector(CustomInfiniteIndicator.restartAnimationIfNeeded), name: NSNotification.Name.UIApplicationWillEnterForeground, object: nil)
    }
    
    private func unregisterFromAppStateNotifications() {
        NotificationCenter.default.removeObserver(self)
    }
    
    private func animation() -> CABasicAnimation {
        let animation = CABasicAnimation(keyPath: "transform.rotation")
        animation.toValue = NSNumber(value: M_PI * 2)
        animation.duration = 1
        animation.repeatCount = Float.infinity
        animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear)
