我想使用CABasicAnimation
. 我想为这个过滤器的一些属性设置动画。我从文档中读到该filters
属性是可动画的,但在同一个文档中,似乎真的很难找到一种方法来做到这一点!
那么,如何使用 animationWithKeyPath 引用 CABasicAnimation 中的单个过滤器属性?
[CABasicAnimation animationWithKeyPath:@"filters._FILTER_._PROPERTY_"];
这是一个完整的示例,只是为了向您展示我是如何让它工作的:
//Define the filter
CIFilter *filterOne = [CIFilter filterWithName:@"CISepiaTone"];
[filterOne setDefaults];
//Attach it to the Layer
self.layer.filters = [NSArray arrayWithObject:filterOne];
//HERE THE PROBLEM ---------------------------------------
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"filters.???????.inputIntensity"];
//EOF HERE THE PROBLEM -----------------------------------
//Define the Animation settings
animation.delegate = self;
animation.fromValue = [NSNumber numberWithInt:0];
animation.toValue = [NSNumber numberWithInt:1];
animation.duration = 0.3;
...etcetc...