在UIView中将背景颜色从一种颜色淡化为另一种颜色

如何在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,帮助每个人学习更多。 :)     
已邀请:
你不需要创建两个UIView和淡入淡出 - 为什么在颜色属性本身可动画的时候还有一个多余的多余视图? 您可以使用如上所示的CAAnimation,但不要调整两个视图的不透明度,只需调整一个的backgroundColor。 http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Animation_Types_Timing/Articles/PropertyAnimations.html     

要回复问题请先登录注册