Question

I used the code below to make transition

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;

but I hope to pause at transition progress 0.3 to do something, then resume the transition to progress 0.6 do something and resume. is it possible ?

Was it helpful?

Solution

I've never worked with CATransition before, but I think you can do this with NSTimer, GCD, or performSelector:withObject:afterDelay:.

For instance:

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];
});

where doSomething is

-(void)doSomething{
    [self pauseLayer:thisLayer];
    //do something
    [self resumeLayer:thisLayer];
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top