我想使用
那么,如何使用
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...
setValue:forKeyPath
将应用于数组的每个元素。对于多个过滤器没有想法... - amadour