Facebook 刚刚开源了他们很棒的 POP 动画 框架,该框架是从 Core Animation 构建的,我不知道如何为图层背景颜色设置动画。
这是我的代码:
POPBasicAnimation *colorAnimation = [POPBasicAnimation animation];
colorAnimation.property = [POPAnimatableProperty propertyWithName:kPOPViewBackgroundColor];
if (_pressed)
{
colorAnimation.toValue = (id)[UIColor redColor].CGColor;
}
else
{
colorAnimation.toValue = (id)[UIColor greenColor].CGColor;
}
[_button pop_addAnimation:colorAnimation forKey:@"colorAnimation"];
.toValue
应该只接受 NSNumber
或 NSValue
但我无法弄清楚如何传入颜色以作为动画.toValue
.
有人知道吗?
最佳答案
好的,我用这段代码解决了这个问题,希望对您有所帮助。我只是将 POPBasicAnimation 更改为 POPSpringAnimation。这是代码
POPSpringAnimation *colorAnimation = [POPSpringAnimation animation];
colorAnimation.property = [POPAnimatableProperty propertyWithName:kPOPViewBackgroundColor];
if (clic)
{
colorAnimation.toValue = (id)[UIColor redColor].CGColor;
}
else
{
colorAnimation.toValue = (id)[UIColor greenColor].CGColor;
}
[imagen pop_addAnimation:colorAnimation forKey:@"colorAnimation"];
关于ios - 如何使用 Facebook Pop Animation Framework 为 UIView 层背景颜色设置动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23376452/