ユーザーが戻るボタンをタップしてルートビューコントローラに戻るときに、アニメーションを実行したいと思います。アニメーションは、ユーザが詳細ビューコントローラで行った変更を単に強調表示します。カスタムアニメーションが完了するまで、viewWillDisappearの実行を待機しますか?
私はこれを試しました。アニメーション自体は機能しています(私の質問には本質的なことではありません。私がやっていることを説明するために残しておきます)。問題は、セグリングが速すぎてアニメーションを見ることができないことです。
アニメーションが完了するまで、どのように私はwait
のviewWillDisappearの実行でできますか?
override func viewWillDisappear(animated: Bool) {
// ...
// Animate if text changes. reminderAfterRulesRun is a custom data structure. reminderNameTextInput is my outlet to my label
if reminderNameTextInput.text != reminderAfterRulesRun.title {
let originalreminderNameTextInputColor = self.reminderNameTextInput.textColor
// Animate the removing of "All" and replacing it with the most commonly used list.
UIView.animateWithDuration(0.3, delay: 0, options: .Autoreverse, animations: {
// Fade out
self.reminderNameTextInput.textColor = UIColor.redColor()
self.reminderNameTextInput.text = reminderAfterRulesRun.title
self.reminderNameTextInput.alpha = 0.0
}, completion: {
(finished: Bool) -> Void in
// Once the label is completely invisible, set the text and fade it back in
UIView.animateWithDuration(0.3, delay: 0, options: .Autoreverse, animations: {
// self.reminderNameTextInput.selectedSegmentIndex = self.toSegmentedControlValue(reminderAfterRulesRun.reminderNameTextInput)!
self.reminderNameTextInput.text = reminderAfterRulesRun.title
self.reminderNameTextInput.textColor = originalreminderNameTextInputColor
self.reminderNameTextInput.alpha = 1.0
}, completion: nil)
})
}
}
私はviewWillDisappearがこれを行うには、適切な場所であるとは思わない:このプロトコルは、移行
してから移行を実行するための呼び出しの時間を求める方法があります。私はあなたがアニメーションのための別の機能を構築することを検討し、あなたがしたいときに欲しいと思うと思う。(アニメーションが終了した後) –
@ウィリアムGPしかし、ユーザーがルートビューコントローラーに戻るときにアニメーションを起こしたい。だから、どうしたらいいの? – Daniel
現在あなたのセグアはどこですか?どのようにトリガーされますか? –