动画完成后如何隐藏我的UIImageView?

时间:2015-04-04 22:38:33

标签: objective-c uiimageview segue uianimation

动画完成后如何隐藏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;
}

2 个答案:

答案 0 :(得分:1)

将动画的委托属性设置为self,如下所示:

animation.delegate = self;

然后你可以使用:

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

动画完成后会调用它。

答案 1 :(得分:-1)

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