I'm doing an animation like this:
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
animation.duration = 100.0;
animation.path = self.animationPath.CGPath;
[view.layer addAnimation:animation forKey:@"animation"];
Works fine, however, this now fails when trying to detect touches on the object that is moving around the screen:
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
{
for (UIView* subview in self.subviews ) {
if ( [subview hitTest:[self convertPoint:point toView:subview] withEvent:event] != nil ) {
[self handleTap];
return YES;
}
}
return NO;
}
It fails because the view's frame is no longer the same as it's apparent position on the screen when it is being animated. How can I get pointInside
to work with a view that is being animated?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…