UIViewである背景色から別の色にフェードするにはどうすればよいですか?
javascript(jQuery)では、次のようにすることで実行できます。
$('body').animate({ backgroundColor: "#ff00ff"});
色をHSVに変換した方が簡単でしょうか?
編集:CABasicAnimationでそれを実行しようとしましたが、不明な理由で白く点滅します。:/
CABasicAnimation* fade = [CABasicAnimation animationWithKeyPath:@"backgroundColor"];
fade.fillMode = kCAFillModeForwards;
fade.removedOnCompletion = NO;
// fade.fromValue = (id)[self.view backgroundColor].CGColor;
fade.toValue = (id)[UIColor greenColor].CGColor;
[self.view.layer addAnimation:fade forKey:@"fade"];
それから私はそれを行う別の方法を見つけようとし、「暗黙のアニメーション」に出くわしました。以下は、ほんの一瞬でうまくいきます。
[UIView beginAnimations:@"fade" context:nil];
[UIView setAnimationDuration:1];
[[self view] setBackgroundColor: [UIColor greenColor]];
[UIView commitAnimations];
StackOverflow、みんながもっと学ぶのを手伝ってくれてありがとう。:)