How can I hide my UIImageView after the animation finishes?

advertisements

How can I hide my UIImageView after the animation is completed? My animation is working fine when I segue into the view. I want to be a able to hide the image after the animation is complete. How might I do that?

-(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;
}


Set the animation's delegate property to self like so:

animation.delegate = self;

And then you can use:

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

It will be called when the animation is done.