まず、値animateWithDuration
とdelay
はfloat
値であり、 と である必要があります1.0
。2.0
意見:コードがViewDidLoad
メソッドにある場合は、別の関数に移動してみてください
第二に、このコンテキストでそれを行うことができない場合は、別のコンテキストにジャンプするか、使用するなどして歩き回ってください
performSelector:withObject:afterDelay
もう 1 つの回避策は、delay
を 0 に設定し、後続のUIView
アニメーション ブロックをcompletion
前のanimateWithDuration
ステートメントのブロックに配置することです。
[UIView animateWithDuration:2.0 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut
animations:^(void) {
//Leave it empty
}
completion:^(BOOL finished){
// Your code goes here
[UIView animateWithDuration:1.0 delay:0.0 options:
UIViewAnimationOptionCurveEaseIn animations:^{
} completion:^ (BOOL completed) {}];
}];
PS:一部のプロパティは、アニメーション ブロック内のテキストの設定など、アニメーション化がサポートされていないため、遅延が終了するとアニメーションが開始され、その変更はアニメーション化できないため、すぐにテキストが変更されます。
テキスト アニメーションの場合、必要なことを行うには、完了ブロックのテキストを次のように変更します。
[UIView animateWithDuration:1.0
delay:2.0
options: UIViewAnimationOptionTransitionCrossDissolve
animations:nil
completion:^{
lbl.text = @"My text" ;
}];
また、でアニメーション化されてbackgroundColor
いませんUIView
。代わりにbackgroundColor
、ビューのlayer
次のプロパティを使用します。
[[controller layer] setBackgroundColor:[[UIColor anyColor] CGColor]];