私がやろうとしているのは、タイマーが鳴ったときにラベルをアニメーション化することです。ウィンドウベースのアプリケーションがあります。
- while ループでコア アニメーションを試しましたが、プログラムがフリーズするだけです。
- タイマー (NSTimer) によってトリガーされるコア アニメーションを試しましたが、何も起こりません。
問題 : プログラムをデバッグしました。すべて正常に見え、すべてのステートメントが実行されていますが、何も起こりません。ループ内またはタイマーによってトリガーされるコアアニメーションは許可されていないと思いました。他の方法はありますか?
私が持っているものは:
drawingTimer = [NSTimer scheduledTimeWithTimeInterval:60.0 target:self
selector:@selector(slideWords) userInfo:nil repeats:NO];
-void (slideWords){
randomNumber = 1 + arc4Random()%2;
if(randomNumber = 1){
Redlabel.alpha = 1.0;
RedLabel.frame = CGRectMake(0, -50, 320, 100);
[UIWindow animateWithDuration:5.0 animations:^{
Redlabel.alpha = 1.0;
Redlabel.frame = CGRectMake(0,300,320,100);
}completion:^(BOOL finished){
[UIWindow animateWithDuration:0.5 delay:0.5 options:0 animations:^{
Redlabel.alpha = 0.0;
}completion:^(BOOL finished){
}];
}];
}
if(randomNumber = 2){
GreenLabel.alpha = 1.0;
GreenLabel.frame = CGRectMake(0, -50, 320, 100);
[UIWindow animateWithDuration:5.0 animations:^{
GreenLabel.alpha = 1.0;
GreenLabel.frame = CGRectMake(0,300,320,100);
}completion:^(BOOL finished){
[UIWindow animateWithDuration:0.5 delay:0.5 options:0 animations:^{
GreenLabel.alpha = 0.0;
}completion:^(BOOL finished){
}];
}];
}
}