@@ -43,6 +43,9 @@ open class SSSpinnerButton: UIButton {
4343
4444 fileprivate var spinnerType : SpinnerType = . ballClipRotate
4545
46+ fileprivate var storedWidth : CGFloat ?
47+ fileprivate var storedHeight : CGFloat ?
48+
4649 /// Sets the button corner radius
4750 @IBInspectable var cornrRadius : CGFloat = 0 {
4851 willSet {
@@ -314,6 +317,8 @@ private extension SSSpinnerButton {
314317 storedHighlightedImage = self . image ( for: . highlighted)
315318
316319 storedBackgroundColor = self . backgroundColor
320+ storedWidth = frame. width
321+ storedHeight = frame. height
317322
318323 self . setImage ( nil , for: . normal)
319324 self . setImage ( nil , for: . disabled)
@@ -358,7 +363,7 @@ private extension SSSpinnerButton {
358363 switch completionType {
359364 case . none:
360365 self . setDefaultDataToButton ( complete: complete)
361- break
366+ return
362367 case . success:
363368 let animation : SSSpinnerAnimationDelegate = SpinnerCompletionType . checkMark. animation ( )
364369 animation. setupSpinnerAnimation ( layer: self . layer, frame: self . frame, color: self . spinnerColor, spinnerSize: self . spinnerSize)
@@ -370,16 +375,21 @@ private extension SSSpinnerButton {
370375 animation. setupSpinnerAnimation ( layer: self . layer, frame: self . frame, color: self . spinnerColor, spinnerSize: self . spinnerSize)
371376 }
372377
373- if setToDefaults {
374- DispatchQueue . main. asyncAfter ( deadline: . now( ) + 1 ) {
375- self . setDefaultDataToButton ( complete: complete)
378+ if completionType != . none {
379+ if setToDefaults {
380+ DispatchQueue . main. asyncAfter ( deadline: . now( ) + 1 ) {
381+ self . setDefaultDataToButton ( complete: complete)
382+ self . isUserInteractionEnabled = true
383+ }
384+ } else {
385+
386+ if complete != nil {
387+ complete!( )
388+ }
376389 self . isUserInteractionEnabled = true
377390 }
378- } else {
379- self . isUserInteractionEnabled = true
380391 }
381-
382-
392+ self . isUserInteractionEnabled = true
383393 }
384394
385395 /// set default state
@@ -421,8 +431,8 @@ private extension SSSpinnerButton {
421431 self . isUserInteractionEnabled = true
422432
423433 let animation = CABasicAnimation ( keyPath: " bounds.size.width " )
424- animation. fromValue = self . frame . height
425- animation. toValue = self . frame . width
434+ animation. fromValue = storedHeight
435+ animation. toValue = storedWidth
426436 animation. duration = self . animationDuration
427437 animation. fillMode = CAMediaTimingFillMode . forwards
428438 animation. isRemovedOnCompletion = false
0 commit comments