【发布时间】:2018-10-09 18:46:42
【问题描述】:
我有一个自定义 CALayer,我在其中尝试使用 actionForKey 并遵循 this tutorial 启用某些属性的动画。
我有一个 CGFloat 属性,在动画块内时会完美改变,但我的另一个属性 UIColor 不会。
这是我的功能:
- (id<CAAction>)actionForKey:(NSString *)event {
if ([self presentationLayer] != nil && [[self class] isCustomAnimationKey:event]) {
id animation = [super actionForKey:@"backgroundColor"];
if (animation == nil || [animation isEqual:[NSNull null]]) {
[self setNeedsDisplay];
return [NSNull null];
}
[animation setKeyPath:event];
[animation setFromValue:[self.presentationLayer valueForKey:event]];
[animation setToValue:nil];
return animation;
}
return [super actionForKey:event];
}
颜色是使用CGContextSetFillColorWithColor 设置的,但我可以从日志中看到颜色只是从一种变化到另一种,没有任何插值。
有什么想法吗?
【问题讨论】:
标签: ios objective-c core-graphics core-animation calayer