Search code examples
iosanimationswift3fadefadeout

Swift 3 Animation: code runs but there is no visual efect


My animation's code gets executed (I can stop the execution with a breakpoint on any of the animation lines) but I visually see nothing. It even takes the second I set for the duration for doing nothing, it just performs the next segue. My text fields should be fading out in 1 sec.

        //animate text fields (fade till dissappear)
        let animationTextFields = {() -> Void in
            self.firstField.alpha = 0.0
            self.secondField.alpha = 0.0
            self.thirdField.alpha = 0.0
            self.fourthField.alpha = 0.0

        }


        UIView.animate(withDuration: 1.0, animations: animationTextFields)


        //animate next button (flies right)

        //animate back button (flies left)

        //animate "please" label (flies up)





        self.performSegue (withIdentifier: "SegueToMainNavigation", sender: self)

As you can see, I also need further animations, but one step at a time.

Any idea why my animation isn't happening?


Solution

  • Put the segue after the animation completes..

      UIView.animate(withDuration: 1.0, delay: 0.0, options: [], animations: animationTextFields, completion: { (finished: Bool) in
                self.performSegue (withIdentifier: "SegueToMainNavigation", sender: self)
        })