0
계산 된 경로를 따라 이미지에 애니메이션을 적용하려고합니다. 다음 코드에서 오류 메시지가 나타나지만 이미지가 움직이지 않습니다. 어떤 도움이 필요합니까?키 프레임 애니메이션
UIImageView *rockHand = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"rockHand" ofType:@"png"]]];
rockHand.frame = CGRectMake(260, -8, 59, 66);
[self.view addSubview:rockHand];
[self.rockHands addObject:rockHand];
int x = 260;
int y = -8;
int spring = 15;
CGMutablePathRef path = CGPathCreateMutable();
CGPathAddLineToPoint(path, nil, x, y);
for (int i = 0; i < 10; i++) {
y += (i*2) - spring;
x += (i * -0.3) ;
spring--;
CGPathAddLineToPoint(path, nil, x, y);
}
CAKeyframeAnimation *anim = [CAKeyframeAnimation animationWithKeyPath:@"position"];
anim.path = path;
anim.duration = 3;
anim.fillMode = kCAFillModeForwards;
anim.calculationMode = kCAAnimationPaced;
anim.removedOnCompletion = NO;
[rockHand.layer addAnimation:anim forKey:@"pathAnimation"];