停止CATransition动画

时间:2012-08-29 09:12:52

标签: iphone 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];

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

2 个答案:

答案 0 :(得分:0)

将动画的速度设置为0以将其暂停,将1设置为再次恢复。 看看https://developer.apple.com/library/ios/#qa/qa2009/qa1673.html

答案 1 :(得分:0)

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

   #import <QuartzCore/QuartzCore.h>

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