     
     func stopAnimating() {
         
-        activityIndicator.stopAnimating()
-        label.alpha = 1
+        //activityIndicator.stopAnimating()
+        self.shapeLayer.removeAllAnimations()
+        
         var scrollView = superview as UIScrollView
         var insets = scrollView.contentInset
         UIView.animateWithDuration(0.3, animations: {

    override init(frame: CGRect) {
        
        pullToRefreshAction = {}
        activityIndicator = UIActivityIndicatorView(activityIndicatorStyle:.White)
        super.init(frame: frame)
        backgroundColor = UIColor.blackColor()
        label.frame = bounds
        label.textAlignment = .Center
        label.textColor = UIColor.whiteColor()
        label.text = "pull to refresh"
        addSubview(label)
        
        activityIndicator.hidesWhenStopped = true
        activityIndicator.center = CGPoint(x: frame.width / 2, y: frame.height / 2)
        addSubview(activityIndicator)
    }
    
    public required init(coder aDecoder: NSCoder) {
        
        pullToRefreshAction = {}
        activityIndicator = UIActivityIndicatorView(activityIndicatorStyle:.White)
        super.init(coder: aDecoder)

        activityIndicator.hidesWhenStopped = true
        activityIndicator.center = CGPoint(x: bounds.width / 2, y: bounds.height / 2)
        addSubview(activityIndicator)
    }
    
    deinit {

        UIView.animateWithDuration(0.3, delay: 0, options:nil, animations: {
            scrollView.contentInset = UIEdgeInsets(top: 50, left: insets.left, bottom: insets.bottom, right: insets.right)
            }, completion: {finished in
                //self.activityIndicator.startAnimating()
                
                var pathAnimationEnd = CABasicAnimation(keyPath: "strokeEnd")
                pathAnimationEnd.duration = 0.5
                pathAnimationEnd.repeatCount = 100
                pathAnimationEnd.autoreverses = true
                pathAnimationEnd.fromValue = 0.2
                pathAnimationEnd.toValue = 1
                self.shapeLayer.addAnimation(pathAnimationEnd, forKey: "strokeEndAnimation")
                
                var pathAnimationStart = CABasicAnimation(keyPath: "strokeStart")
                pathAnimationStart.duration = 0.5
                pathAnimationStart.repeatCount = 100
                pathAnimationStart.autoreverses = true
                pathAnimationStart.fromValue = 0
                pathAnimationStart.toValue = 0.8
                self.shapeLayer.addAnimation(pathAnimationStart, forKey: "strokeStartAnimation")
                
                
                self.pullToRefreshAction()
                scrollView.bounces = true
        })
