ユーザーの進行状況に基づいてメッセージをアニメーション化するアプリケーションの一部に取り組んでいます。したがって、本質的にメッセージはタイムアウトしました。
カウンターと 2 つのラベルがあります。
var timer = NSTimer()
var timerCount = 0
@IBOutlet weak var bannerLabel: UILabel!
@IBOutlet weak var messageLabel: UILabel!
timerCount
変数がインクリメントされるカウント メソッド (countingUp) を呼び出す NSTimer があります。もちろん、このメソッドは予想どおり毎秒起動します。メソッドは (毎秒)というcountingUp
メソッドを呼び出しますupdateLabels
。
func countingUp() {
// other irrelevant stuff
updateLabels()
timerCount++
}
func updateLabels() {
if timerCount == 1 {
animateMessage(messageLabel, delay: 7.0)
animateBanner(bannerLabel, delay: 7.0)
bannerLabel.text = "Message 1"
messageLabel.text = "Blah Blah"
}
// quite a few more of these conditions, though
// I use a switch in my app.
}
そして、ここに私のアニメーション方法があります:
func animateBanner(banner: UILabel, delay: Double){
UIView.animateWithDuration(1.2, animations: {
banner.alpha = 1.0
})
if delay > 0.0 {
UIView.animateWithDuration(3, delay: delay, options: [], animations: {
banner.alpha = 0.1
}, completion: nil)
}
}
func animateMessage(label: UILabel, delay: Double){
label.alpha = 0.0
UIView.animateWithDuration(1.2, animations: {
label.center.y -= 20
label.alpha = 1.0
})
UIView.animateWithDuration(1.2, delay: delay, options: [], animations: {
label.alpha = 0.1
}, completion: nil)
}
メソッドが呼び出されていること、およびラベルが実際にアルファ版であることを証明するために0
、スクリーン ショットを撮りました。
私の質問:
私のアニメーションは完全にフェードアウトしますが、フェードインすることはなく、表示されるだけです。これの理由は何ですか?