首页 > 学院 > 开发设计 > 正文

IOS/Swift暂停和恢复图层动画

2019-11-14 19:30:08
字体:
来源:转载
供稿:网友

开始图层动画的代码: 

   //mySuperLayer父图层    CFTimeInterval pausedTime = [self.mySuperLayer timeOffset];    if (pausedTime > 0)//在暂停后才能使用    {        self.mySuperLayer.speed = 1.0;        self.mySuperLayer.timeOffset = 0.0;        self.mySuperLayer.beginTime = 0.0;        CFTimeInterval timeSincePause = [self.mySuperLayer convertTime:CACurrentMediaTime() fromLayer:nil] - pausedTime;        self.mySuperLayer.beginTime = timeSincePause;    }

 暂停图层动画的代码:

    CFTimeInterval pausedTime = [self.mySuperLayer convertTime:CACurrentMediaTime() fromLayer:nil];    self.mySuperLayer.speed = 0.0;    self.mySuperLayer.timeOffset = pausedTime;

 

例子下载:https://github.com/yoimhere/ZJLoadView/archive/master.zip

 

  


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表