[英]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.