ios - 如何使用 Facebook Pop Animation Framework 为 UIView 层背景颜色设置动画?

标签 ios objective-c animation core-animation facebook-pop

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 应该只接受 NSNumberNSValue 但我无法弄清楚如何传入颜色以作为动画.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/

相关文章:

ios - 无法从 iOS 中的 BLE 设备获取数据/服务

ios - 在导入 Swift header 的桥接 header 中导入文件

python - 如何使用 matplotlib.animation 从动态增长的列表中连续流式传输数据点以进行实时绘图?

html - 动画 SVG 图像

ios - Cocos2d for iPhone 中高效的逐帧动画

ios - 如何快速从 Eureka 表单中提取值到局部变量?

ios - shouldChangeCharactersInRange 调用两次

ios - 从 PhoneGap iOS 应用程序中删除文本选择

ios - Swift 等效于静态 Objective-C 表达式

ios - 如何从NSString中删除08十六进制字符