0
애니메이션의 중간에있는 UIImageView 애니메이션 최종 목적지 등의 위치 및 이동 이미지를 터치를 감지하기 위해, 나는 표현 계층을 사용할 필요가 :내가 바로 화면을 가로 질러 왼쪽으로 이동되는 개체가
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesBegan:touches withEvent:event];
UITouch *touch = [touches anyObject];
CGPoint touchPoint = [touch locationInView:self.view];
if ([myImageview.layer.presentationLayer hitTest:touchPoint]) {
NSLog(@"it's a hit!");
}
}
이 부분은 작동합니다. 이제 이미지를 눌렀을 때 위로 움직이고 싶습니다. 이미지가 옆으로 움직이는 동안 계속 움직이기를 원합니다. 대신,이 코드는하지 그냥 이미지를 이동뿐만 아니라 왼쪽에 최종 목적지에있는 모든 방법 :
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesBegan:touches withEvent:event];
UITouch *touch = [touches anyObject];
CGPoint touchPoint = [touch locationInView:self.view];
if ([mouse.layer.presentationLayer hitTest:touchPoint]) {
NSLog(@"it's a hit!");
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
myImageView.layer.position = CGPointMake(mouse.layer.position.x, myImageView.layer.position.y - 40);
[UIView commitAnimations];
}
}
나는 그것이 운동 옆의 계속하면서 이미지가 이동하려는. 누구든지이 작업을 수행하는 방법을 알고 있습니까?
감사합니다.
굉장! 내가 완전히 알지 못했던 훌륭한 선택이었습니다! – RanLearns
매우 흥미 롭습니다. 이전 애니메이션 대신 사용됩니다. 원래 애니메이션을 x 축에 영향을주고 y 축에 애니메이션을 추가하기 때문에 계속 진행하려고했습니다. 이것은 흥미로운 옵션이지만, 여전히 작동하지 않을 것입니다. 왜냐하면 이미지 뷰를 움직일뿐만 아니라 왼쪽의 최종 목적지로 보냅니다. 정말 고마워! 이 새로운 옵션으로 놀 수 있습니다. =) – RanLearns
원하는 최종 결과를 얻으려면 애니메이션 매개 변수를 다시 계산하고 변경해야합니다. –