【问题标题】:pause catransition and resume暂停转换和恢复
【发布时间】:2012-11-04 08:15:44
【问题描述】:

我使用下面的代码进行过渡

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 做某事并继续。 有可能吗?

【问题讨论】:

    标签: iphone objective-c ios catransition


    【解决方案1】:

    我以前从未使用过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];
    }
    

    【讨论】:

      猜你喜欢
      • 2013-07-19
      • 2015-07-28
      • 2014-12-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多