フィルタアニメーションのやり方がわからない...
Posted 7月 11th, 2010 by hippos
テキストフィールドにフィルタをかけたるアニメーションを実装したいと思ったのですがなかなか思う通りにできません。みるくCocoaさんのサンプルにまさにコレ!というのがあったので早速試したのですが、デフォ0.25秒の動きが早すぎるのかどうしてもアニメーションしているようには見えませんでした。本家アップルの例のように、
CABasicAnimation *theAnimation =
[CABasicAnimation animationWithKeyPath:@"filters.myGussian.inputRadius"];
theAnimation.duration = 10;
theAnimation.fromValue = [NSNumber numberWithFloat:5.0];
theAnimation.toValue = [NSNumber numberWithFloat:0.0];
[[answerField layer] addAnimation:theAnimation forKey:@"filterAnimation"];のように書き直しても動く気配なし。そもそもCore ImageとかCore Animationとか全然わかっていないのでコードの断片だけを拾い集めてきてもうまくいくはずもなく、アニメーションはあきらめて
if ([text wantsLayer])
{
[text setWantsLayer:NO];
[text setContentFilters:nil];
return;
}
CIFilter *filter = [CIFilter filterWithName:@"CIGaussianBlur" keysAndValues:
kCIInputRadiusKey, [NSNumber numberWithFloat:2.5], nil];
[text setContentFilters:[NSArray arrayWithObject:filter]];
[text setWantsLayer:YES];として、フィルタの適用をオン・オフだけするだけの実装にしてごまかして(実際これだけでも十分なんですが...)Core mage/Core Animation周りを勉強し直すことにしました。というわけで、これをポチ。
![]() |
Core Animation for Max OS X and the iPhone: Creating Compelling Dynamic User Interfaces (Pragmatic Programmers) Bill Dudney Pragmatic Bookshelf 2008-10-15 |
この記事のトラックバックURL:
http://hippos-lab.com/blog/trackback/373







Comments