暂停过渡和恢复

时间:2012-11-04 08:15:45

标签: iphone objective-c ios catransition

我使用下面的代码进行转换

CATransition *transition = [CATransition animation];
transition.duration = duration ;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];

transition.type = kCATransitionMoveIn;

transitioning = YES;
transition.delegate = self;

[self.view.layer addAnimation:transition forKey:nil];


fromUIView.hidden = YES;
toUIView.hidden = NO;

UIImageView *tmp = toUIView;
toUIView = fromUIView;
toUIView = tmp;

但我希望暂停过渡进度0.3做一些事情,然后恢复过渡到进展0.6做一些事情并恢复。 有可能吗?

1 个答案:

答案 0 :(得分:0)

我之前从未与CATransition合作,但我认为您可以使用NSTimerGCDperformSelector:withObject:afterDelay:来完成此操作。

例如:

double delayInSeconds = 0.3;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
    [self doSomething];
});

其中doSomething

-(void)doSomething{
    [self pauseLayer:thisLayer];
    //do something
    [self resumeLayer:thisLayer];
}