我正在尝试使用核心动画将文本字段突出显示为无效.
[[my_field animator] setBackgroundColor [NSColor yellowColor]]
Run Code Online (Sandbox Code Playgroud)
更新字段背景颜色,但不为更改设置动画.更新属性(例如字段的位置)可以正确设置动画.我假设这是因为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"];
Run Code Online (Sandbox Code Playgroud)
有关完成此事的建议吗?