【发布时间】:2011-01-10 01:13:52
【问题描述】:
我正在尝试使用核心动画来突出显示无效的文本字段。
[[my_field animator] setBackgroundColor [NSColor yellowColor]]
更新字段背景颜色,但不为更改设置动画。更新属性(例如字段的位置)会正确设置动画。我假设这是因为背景颜色不包含在 NSAnimatablePropertyContainer 搜索中。
我也尝试过显式创建动画,但无济于事。
CABasicAnimation *ani;
ani = [CABasicAnimation animationWithKeyPath:@"backgroundColor"];
ani.fromValue = CGColorCreateGenericRGB(1.0,1.0,1.0,1.0);
ani.toValue = CGColorCreateGenericRGB(1.0,0.0,0.0,1.0);
ani.repeatCount = 2;
ani.autoreverses = YES;
ani.duration = 1.0;
[[my_field layer] addAnimation:ani forKey:"backgroundColor"];
对完成这项工作的建议?
【问题讨论】:
标签: objective-c cocoa macos core-animation