我使用下面的代码进行转换
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做一些事情并恢复。 有可能吗?
答案 0 :(得分:0)
我之前从未与CATransition
合作,但我认为您可以使用NSTimer
,GCD
或performSelector: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];
}