         fade.toValue = recording ? 1.0 : 0.0
         fade.duration = duration
         fade.fillMode = kCAFillModeForwards
-        fade.removedOnCompletion = false
-        
-        circleLayer.addAnimation(circleAnimations, forKey: "circleAnimations")
-        progressLayer.addAnimation(fade, forKey: "fade")
-        circleBorder.addAnimation(borderAnimations, forKey: "borderAnimations")
-        
-    }
-    
-    private func gradientMask() -> CAGradientLayer {
+        fade.isRemovedOnCompletion = false
+        
+        circleLayer.add(circleAnimations, forKey: "circleAnimations")
+        progressLayer.add(fade, forKey: "fade")
+        circleBorder.add(borderAnimations, forKey: "borderAnimations")
+        
+    }
+    
+    fileprivate func gradientMask() -> CAGradientLayer {
         let gradientLayer = CAGradientLayer()
         gradientLayer.frame = self.bounds
         gradientLayer.locations = [0.0, 1.0]
         let topColor = progressColor
         let bottomColor = progressColor
-        gradientLayer.colors = [topColor.CGColor, bottomColor.CGColor]
+        gradientLayer.colors = [topColor?.cgColor as Any, bottomColor?.cgColor as Any]
         return gradientLayer
     }
     
-    override func layoutSubviews() {
-        circleLayer.anchorPoint = CGPointMake(0.5, 0.5)
-        circleLayer.position = CGPointMake(CGRectGetMidX(self.bounds),CGRectGetMidY(self.bounds))
-        circleBorder.anchorPoint = CGPointMake(0.5, 0.5)
-        circleBorder.position = CGPointMake(CGRectGetMidX(self.bounds),CGRectGetMidY(self.bounds))
+    override open func layoutSubviews() {
+        circleLayer.anchorPoint = CGPoint(x: 0.5, y: 0.5)
+        circleLayer.position = CGPoint(x: self.bounds.midX,y: self.bounds.midY)
+        circleBorder.anchorPoint = CGPoint(x: 0.5, y: 0.5)
+        circleBorder.position = CGPoint(x: self.bounds.midX,y: self.bounds.midY)
         super.layoutSubviews()
     }
     
     
-    internal func didTouchDown(){
-        self.buttonState = .Recording
-    }
-    
-    internal func didTouchUp() {
+    @objc open func didTouchDown(){
+        self.buttonState = .recording
+    }
+    
+    @objc open func didTouchUp() {
         if(closeWhenFinished) {
             self.setProgress(1)
-
-            UIView.animateWithDuration(0.3, animations: {
-                self.buttonState = .Hidden
+            
+            UIView.animate(withDuration: 0.3, animations: {
+                self.buttonState = .hidden
                 }, completion: { completion in
                     self.setProgress(0)
                     self.currentProgress = 0
             })
         } else {
-            self.buttonState = .Idle
-        }
-    }
-    
-    
-    internal func setProgress(newProgress: CGFloat) {
+            self.buttonState = .idle
+        }
+    }
+    
+    
+    /**
+    Set the relative length of the circle border to the specified progress
+    
+    - parameter newProgress: the relative lenght, a percentage as float.
+    */
+    open func setProgress(_ newProgress: CGFloat) {
         progressLayer.strokeEnd = newProgress
     }
     

        let borderColor: CABasicAnimation = CABasicAnimation(keyPath: "borderColor")
        borderColor.duration = duration
        borderColor.fillMode = kCAFillModeForwards
        borderColor.removedOnCompletion = false
        borderColor.toValue = recording ? UIColor(red: 0.83, green: 0.86, blue: 0.89, alpha: 1).CGColor : buttonColor
        
        let borderScale = CABasicAnimation(keyPath: "transform.scale")
        borderScale.fromValue = recording ? 1.0 : 0.88
        borderScale.toValue = recording ? 0.88 : 1.0
        borderScale.duration = duration
        borderScale.fillMode = kCAFillModeForwards
        borderScale.removedOnCompletion = false
        
        let borderAnimations = CAAnimationGroup()
        borderAnimations.removedOnCompletion = false
        borderAnimations.fillMode = kCAFillModeForwards
        borderAnimations.duration = duration
        borderAnimations.animations = [borderColor, borderScale]

        scale.toValue = recording ? 0.88 : 1
        scale.duration = duration
        scale.fillMode = kCAFillModeForwards
        scale.isRemovedOnCompletion = false
        
        let color = CABasicAnimation(keyPath: "backgroundColor")
        color.duration = duration
        color.fillMode = kCAFillModeForwards
        color.isRemovedOnCompletion = false
        color.toValue = recording ? progressColor.cgColor : buttonColor.cgColor
        
        let circleAnimations = CAAnimationGroup()
        circleAnimations.isRemovedOnCompletion = false
        circleAnimations.fillMode = kCAFillModeForwards
        circleAnimations.duration = duration
        circleAnimations.animations = [scale, color]
