     
     lazy var spiner: SpinerLayer! = {
         let s = SpinerLayer(frame: self.frame)
-        self.layer.addSublayer(s)
         return s
     }()
     

        let a = anim as! CABasicAnimation
        if a.keyPath == "transform.scale" {
            didEndFinishAnimation?()
            Timer.schedule(delay: 1) { timer in
                self.returnToOriginalState()
            }
        }
    }
    
    open func returnToOriginalState() {
        
        self.layer.removeAllAnimations()
        self.setTitle(self.cachedTitle, for: UIControlState())
        self.spiner.stopAnimation()
    }
    
    func shrink() {
        let shrinkAnim = CABasicAnimation(keyPath: "bounds.size.width")
        shrinkAnim.fromValue = frame.width
        shrinkAnim.toValue = frame.height
        shrinkAnim.duration = shrinkDuration

            self.layer.cornerRadius = normalCornerRadius
        }
    }
    
    var cachedTitle: String?
    var isAnimating = false

    public override init(frame: CGRect) {
        super.init(frame: frame)
        self.setup()
    }
    
    public required init!(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)!
        self.setup()
    }
    
    func setup() {
        self.clipsToBounds = true
        spiner.spinnerColor = spinnerColor
    }
    
    open func startLoadingAnimation() {
        self.isAnimating = true
        self.cachedTitle = title(for: UIControlState())
        self.setTitle("", for: UIControlState())
        self.layer.addSublayer(spiner)
        
        // Animate
        self.cornerRadius()
        self.shrink()
        _ = Timer.schedule(delay: self.shrinkDuration - 0.25) { timer in
            self.spiner.animation()
        }
    }
    
    open func startFinishAnimation(_ delay: TimeInterval,_ animation: CAMediaTimingFunction, completion:(()->())?) {
        self.isAnimating = true
        _ = Timer.schedule(delay: delay) { timer in
            self.didEndFinishAnimation = completion
            self.expand(animation)
            self.spiner.stopAnimation()
        }
    }
    
    open func animate(_ duration: TimeInterval,_ animation: CAMediaTimingFunction, completion:(()->())?) {
        startLoadingAnimation()
        startFinishAnimation(duration, animation, completion: completion)
    }
    
    open func setOriginalState() {
        self.returnToOriginalState()
        self.spiner.stopAnimation()
