2012-08-29 69 views
1

我使用这个代码,以使纹波动画我看来停止CATransition动画

transition = [CATransition animation]; 
    transition.delegate = self; 
    transition.duration = 3; 
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; 
    NSString *types[4] = {@"cube", @"rippleEffect", @"cube", @"alignedCube"}; 
    NSString *subtypes[4] = {kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromRight}; 
    transition.type = types[1]; 
    transition.subtype = subtypes[1]; 

现在我想用自来水的手段来停止动画之后,我想从视图开始,我停止....

我试图为

[view.layer removeAllAnimations];

但我发现下面的东西不起作用..任何建议?

回答

0

您可以从CALayer中获取当前动画状态。

#import <QuartzCore/QuartzCore.h> 

    myView.layer.modelLayer.frame = myView.layer.presentationLayer.frame; 
+0

@B Visschers Y我需要这个吗? – Icoder

+0

如果您想停止中间的动画,并保持原样(不会将视图重置为动画开始之前),那么您需要这样做。 – Berik

+0

还有其他方法可以做到这一点。查看关于[Core Animation]的大量文档(http://developer.apple.com/library/ios/#DOCUMENTATION/Cocoa/Conceptual/CoreAnimation_guide/Introduction/Introduction.html)。 – Berik