アニメーションの終了後にセグを実行しようとしています。アニメーションの終了後にセグを実行する
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.center = CGPoint(x: 50,y:300)
self.label.alpha = 0.0
}, completion: nil)
}
if label.alpha == 0.0 {
UIView.animateWithDuration(0.5, delay: 10.0, usingSpringWithDamping: 0.0, initialSpringVelocity: 0.0, options: .CurveEaseOut, animations: {() -> Void in
self.performSegueWithIdentifier("backSegue", sender: self)
}, completion: nil)
}
}
だから基本的に私は下に移動し、フェードアウトのラベル(第1および第2 animateWithDuration)が、その後、私はラベルがフェードアウトされた後にセグエが発生します:ここで私はviewDidAppearを持っているコードがありますもう一方のアニメーションが行われます。現在、セグエは起きていますが、すぐにやりますが、どれだけ遅れても待ちません。
関数が完了した後にアクションを実行する場合は、「完了」ブロックでコードをコーディングする必要があります。メソッドが終了したら完了ブロックが呼び出されます。 – Bharath
答えを更新しました –