动画后执行segue需要很长时间

时间:2016-05-12 16:10:12

标签: ios xcode swift swift2 xcode6

我正在尝试在Swift的动画完成块中执行segue。然而,segue需要很长时间(大约10秒)才能完成,我不知道为什么。这是代码:

override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)

        imageViewAnimated.startAnimating()


        if label.center != CGPoint(x:50, y:10) {

            UIView.animateWithDuration(2.0, delay: 0.0, usingSpringWithDamping: 0.0, initialSpringVelocity: 0.0, options: .CurveEaseOut, animations: { () -> Void in
                self.label.center = self.view.center

                }, completion: nil)

            UIView.animateWithDuration(0.5, delay: 0.0, usingSpringWithDamping: 0.0, initialSpringVelocity: 0.0, options: .CurveEaseOut, animations: { () -> Void in
                self.label.alpha = 0.0

                }, completion: { finished in

                    self.poof.alpha = 1.0
                    self.performSegueWithIdentifier("backSegue", sender: nil)
            })
        }
    }

1 个答案:

答案 0 :(得分:0)

 override func viewDidAppear(animated: Bool) {
            super.viewDidAppear(animated)

            imageViewAnimated.startAnimating()


            if label.center != CGPoint(x:50, y:10) {

                UIView.animateWithDuration(2.0, delay: 0.0, usingSpringWithDamping: 0.0, initialSpringVelocity: 0.0, options: .CurveEaseOut, animations: { () -> Void in
                    self.label.center = self.view.center

                    }, completion: nil)

                UIView.animateWithDuration(0.5, delay: 0.0, usingSpringWithDamping: 0.0, initialSpringVelocity: 0.0, options: .CurveEaseOut, animations: { () -> Void in
                    self.label.alpha = 0.0

                    }, completion: { finished in

                        self.poof.alpha = 1.0
                        dispatch_async(dispatch_get_main_queue(),{
                            self.performSegueWithIdentifier("backSegue", sender: nil)
                        })
                })
            }
        }