У меня есть объект UIImageview, движущийся по пути, и я использую анимацию CABasic и BezierCure для перемещения объекта по пути. Теперь проблема заключается в том, что если я касаюсь движущегося объекта, событие касания не распознается UIImageView, но касание событие получено основным видом. Кто-нибудь может помочь мне решить эту проблему?
Ниже мой код
UITouch *touch = [[event allTouches] anyObject];
if (![touch.view isEqual: beaconPose1]) {
return;
}
[touch.view.layer removeAllAnimations];
CGPoint location = [touch locationInView: self.view];
CGRect frame = touch.view.frame;
frame.origin.x = location.x;
frame.origin.y = location.y;
///frame.origin.x += xDisplacement;
//frame.origin.y += yDisplacement;
touch.view.frame = frame;
- Код, где включено взаимодействие с пользователем
[beaconPose1 setUserInteractionEnabled:true];
CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
pathAnimation.duration = 1.0f;
pathAnimation.path = beaconPose3Path.CGPath;
pathAnimation.calculationMode = kCAAnimationLinear;
CABasicAnimation *fullRotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
fullRotation.fromValue = [NSNumber numberWithFloat:0];
fullRotation.toValue = [NSNumber numberWithFloat:((360*M_PI)/180)];
fullRotation.duration = pathAnimation.duration;
fullRotation.repeatCount = pathAnimation.duration/fullRotation.duration;
[beaconPose1.layer addAnimation:fullRotation forKey:@"360"];
[beaconPose1.layer addAnimation:pathAnimation forKey:@"movingAnimation"];