繁体   English   中英

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

[英]How to animate a CIFilter with CoreAnimation in iOS?

我想使用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...

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

文件说:

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM