我的动画效果是把一个UIView对象绕着一个点旋转,但是旋转完之后就不能响应触摸事件了,怎么点都没反应。
我后来发现点击View原来的位置时能响应,是不是有一个负责响应触摸的层没有移过去?求助!
我的代码是这样的:    PbTestViewController *leafViewController = [[PbTestViewController alloc]init];
    
    CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
    animation.delegate = self;
    [animation setValue:leafViewController forKey:@"leaf"];
    animation.duration = 0.1;
    animation.removedOnCompletion = NO;
    animation.fillMode = kCAFillModeForwards;
    CGMutablePathRef path = CGPathCreateMutable();
    
    CGPathAddArc(path, NULL, self.view.bounds.size.width/2, self.view.bounds.size.height/2, ROUND_RADIUS+leafViewController.view.frame.size.height/2.0f, (angle+0.001f)*M_PI/180.0f, (angle)*M_PI/180.0f, YES);
    
    animation.path = path;
    CGPathRelease(path);
    
    [leafViewController.view.layer addAnimation:animation forKey:@"somekey"];
    
uiviewanimationpathiOSxcode

解决方案 »

  1.   

    仅仅是把layer转过去了啊。
    view没有动。你应该重新设置view的frame。
      

  2.   

    可是怎么知道移动后的frame呢?
      

  3.   

    问题解决了!
    在动画结束的消息中添加以下代码:
    - (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag {
        PbLeafViewController *leafViewController = [anim valueForKey:@"leaf"];
        
        if (flag && leafViewController) {
            CGPoint currentRect = [[leafViewController.view.layer presentationLayer]position];
            leafViewController.view.layer.position = currentRect;
            return;
        }
    }