gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 05:08:48 26 4
gpt4 key购买 nike

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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com