我正在尝试在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)
})
}
}
答案 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)
})
})
}
}