Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

animation inside completion block does not Animte #45

Open
minaMagedNaeem opened this issue Aug 8, 2019 · 0 comments
Open

animation inside completion block does not Animte #45

minaMagedNaeem opened this issue Aug 8, 2019 · 0 comments

Comments

@minaMagedNaeem
Copy link

If I put an animation block inside the stop animation completion block, It does not animate anything. Here is a sample code:

@IBAction func redeemPPressed(_ sender: Any) {
        let button = sender as! TransitionButton
        button.startAnimation() // 2: Then start the animation when the user tap the button
        let qualityOfServiceClass = DispatchQoS.QoSClass.background
        let backgroundQueue = DispatchQueue.global(qos: qualityOfServiceClass)
        backgroundQueue.async(execute: {
            
            sleep(1) // 3: Do your networking task or background work here.
            
            DispatchQueue.main.async(execute: { () -> Void in
                // 4: Stop the animation, here you have three options for the `animationStyle` property:
                // .expand: useful when the task has been compeletd successfully and you want to expand the button and transit to another view controller in the completion callback
                // .shake: when you want to reflect to the user that the task did not complete successfly
                // .normal
                
                button.stopAnimation(animationStyle: .normal,revertAfterDelay: 1.0,completion: {
                    UIView.animate(withDuration: 1.0, animations: {
                        button.isHidden = true
                        self.codeView.isHidden = false
                    })
                })
            })
        })
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant