2015-04-04 62 views
1

动画完成后,如何隐藏我的UIImageView?当我进入视图时,我的动画工作正常。我希望能够在动画完成后隐藏图像。我该怎么做?如何在动画完成后隐藏我的UIImageView?

-(void) animate 
{ 
    NSLog(@"Animate"); 

    CGPoint startPoint = [pickerCircle center]; 
    CGPoint endPoint = [pickerButton1 center]; 

    CGMutablePathRef thePath = CGPathCreateMutable(); 
    CGPathMoveToPoint(thePath, NULL, startPoint.x, startPoint.y); 
    CGPathAddLineToPoint(thePath, NULL, endPoint.x, endPoint.y); 

    CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"]; 
    animation.duration = 3.f; 
    animation.path = thePath; 
    animation.repeatCount = 2; 
    animation.removedOnCompletion = YES; 
    [pickerCircle.layer addAnimation:animation forKey:@"position"]; 
    pickerCircle.layer.position = endPoint; 
} 

回答

-1

您是否尝试完成? Here example 4.2有一个关于使用完成来显示和隐藏视图的示例。 我不太了解动画,但我认为完成应该可行。

+0

对不起,这并不能真正回答我的问题。是的,我在使用'completion':blocks的其他类型的动画中看到了一些示例,我正在专门寻求'CAKeyframeAnimation'的帮助。 – 2015-04-04 23:01:52

1

设置动画的委托财产的自我,像这样:

animation.delegate = self; 

然后你可以使用:

-(void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag { 
    // hide your UIImage here 
} 

当动画完成后它就会被调用。