开始图层动画的代码:
//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;
网友评论