ここで私のコードはUIview 30pxをy = 10まで移動しますが、このアニメーションは機能しません。これはCAKeyframeAnimationを作成する私の最初の試みです。だから、誰でも私が正しくそれを書くのを助けることができます。また、私のオブジェクトを元の場所に戻ってくるのではなく、アニメーションが終了した場所に残しておきたい。CAKeyframeanimationは、パスに沿ってUIViewを移動します
CGMutablePathRef thePath = CGPathCreateMutable();
CGPathAddRect(thePath, NULL, CGRectMake(self.logo.frame.origin.x, self.logo.frame.origin.y, self.logo.frame.size.width, self.logo.frame.size.height));
CGPathAddRect(thePath, NULL, CGRectMake(self.logo.frame.origin.x, self.logo.frame.origin.y-30, self.logo.frame.size.width, self.logo.frame.size.height));
CGPathAddRect(thePath, NULL, CGRectMake(self.logo.frame.origin.x, 100, self.logo.frame.size.width, self.logo.frame.size.height));
CAKeyframeAnimation* AniLoc = [CAKeyframeAnimation animationWithKeyPath:@"frame"];
AniLoc.path = thePath;
AniLoc.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
AniLoc.keyTimes= [NSArray arrayWithObjects:[NSNumber numberWithFloat:0.0f],
[NSNumber numberWithFloat:0.3f],
[NSNumber numberWithFloat:1.0f],nil];
AniLoc.duration = 2.0;
CFRelease(thePath);
[self.logo.layer addAnimation:AniLoc forKey:nil];
どのように「機能しない」のですか? – jrturton
アニメーションは何も動かない –