如何在iOS中使用CoreAnimation为CIFilter制作动画?

Mat*_*oal 3 core-animation core-image calayer ios

我想使用过滤器添加过滤器CABasicAnimation.我想为这个过滤器的一些属性设置动画.我从文档中读到该filters属性是可动画的,但在相同的文档中,似乎很难找到一种方法来做到这一点!

那么,我如何使用animationWithKeyPath从CABasicAnimation引用单个过滤器属性?

[CABasicAnimation animationWithKeyPath:@"filters._FILTER_._PROPERTY_"];
Run Code Online (Sandbox Code Playgroud)

这是一个完整的例子,只是为了告诉你我是如何让它工作的:

//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...
Run Code Online (Sandbox Code Playgroud)

Dun*_*n C 6

我认为图层过滤器属性在iOS中根本不起作用.最近在Apple网站上的Apple Core动画论坛上讨论了这个问题,而一位名叫"Rincewind"的苹果工程师发布了根本没有为iOS实现的图层过滤功能.

文件说:

iOS注意:虽然iOS中的CALayer类公开了filters属性,但Core Image不可用.目前,此属性可用的过滤器未定义.

据我所知,你只能通过直接调用它们并使用CIImage作为输出来使用CI过滤器.然后,您必须通过代码使用CIImage.