takuoka / TKSubmitTransition

Animated UIButton of Loading Animation and Transition Animation. Inspired by https://dribbble.com/shots/1945593-Login-Home-Screen
MIT License
2.28k stars 229 forks source link

TKSubmitTransitionButton. How do i stop a button from transition/ animating when user login/ signup are incorrect #49

Open chatarveer opened 6 years ago

chatarveer commented 6 years ago

Its creating color on navigation and If I show UIAlertController, it messed all.

How to stop with without animation--- make it back to simple button if response is error. Its spreading red color/ color of button over Navigation background....

iMattin commented 6 years ago

You should change some lines of 'TransitionSubmitButton.swift'. to do this, follow these short steps:

1- Jump to definition of 'startFinishAnimation' method which written in 'TransitionSubmitButton.swift'

2- Change this method to:

open func startFinishAnimation(_ delay: TimeInterval , animate: Bool, completion:(()->())?) {
        if !animate {
           self.spiner.stopAnimation()
           self.returnToOriginalState()
           return
        }
        Timer.schedule(delay: delay) { timer in
            self.didEndFinishAnimation = completion
            self.expand()
            self.spiner.stopAnimation()
        }
    }

3- In 'TransitionSubmitButton.swift', find startFinishAnimation(duration, completion: completion) and replace it to: startFinishAnimation(duration , animate: true, completion: completion)

4- Done! now if user entered incorrect info, use this:

loginBtn.startFinishAnimation(0.0 , animate: false, completion:{
       // alert user...
})
treyholt commented 6 years ago

Just tried this and now it seems it never stops spinning.

salil09 commented 6 years ago

Call returnToOriginalState() instead of startFinishAnimation.