コアアニメーションは初めてです。アニメーションを呼び出すたびに、画像がその場所から画面の左上に移動し、移動してから元の場所に戻ります。画像を左に 50 単位移動させて停止し、もう一度ボタンを押すと繰り返すにはどうすればよいですか。コード:
-(IBAction)preform:(id)sender{
CGPoint point = CGPointMake(50, 50);
CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"position"];
anim.fromValue = [NSValue valueWithCGPoint:point];
anim.toValue = [NSValue valueWithCGPoint:CGPointMake(point.x + 50, point.y)];
anim.duration = 1.5f;
anim.repeatCount =1;
anim.removedOnCompletion = YES;
anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
[imView.layer addAnimation:anim forKey:@"position"];
}