を使用CAKeyframeAnimation
して、オブジェクトを小さな円またはニーズに合ったその他のパスに沿って移動させることができます。CAKeyframeAnimation
オブジェクトを作成して使用する方法は次のとおりです。
CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
pathAnimation.calculationMode = kCAAnimationPaced;
pathAnimation.fillMode = kCAFillModeForwards;
pathAnimation.removedOnCompletion = NO;
CGMutablePathRef * circle = CGPathCreateWithEllipseInRect(CGRectMake(/* the center of your object and the radius of your circle*/));
pathAnimation.path = circle;
CGPathRelease(circle);
[buttonView.layer addAnimation:pathAnimation forKey:@"animatePath"];
これで始められるはずです。これを機能させるには、QuartzCore フレームワークをインポートする必要があることに注意してください。