2015-04-04 21 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 
} 

當動畫完成後它就會被調用。