如何在ios中运用core animation暂停和继续动画
1个回答
推荐于2016-11-10
展开全部
如何在ios中运用core
animation暂停和继续动画
核心代码如下
//暂停layer上面的动画
-
(void)pauseLayer:(CALayer*)layer
{
CFTimeInterval pausedTime = [layer
convertTime:CACurrentMediaTime() fromLayer:nil];
layer.speed = 0.0;
layer.timeOffset = pausedTime;
}
//继续layer上面的动画
-
(void)resumeLayer:(CALayer*)layer
{
CFTimeInterval pausedTime = [layer
timeOffset];
layer.speed = 1.0;
layer.timeOffset = 0.0;
layer.beginTime = 0.0;
CFTimeInterval timeSincePause = [layer
convertTime:CACurrentMediaTime() fromLayer:nil] - pausedTime;
layer.beginTime = timeSincePause;
}
转载,仅供参考,祝你愉快,满意请采纳。
animation暂停和继续动画
核心代码如下
//暂停layer上面的动画
-
(void)pauseLayer:(CALayer*)layer
{
CFTimeInterval pausedTime = [layer
convertTime:CACurrentMediaTime() fromLayer:nil];
layer.speed = 0.0;
layer.timeOffset = pausedTime;
}
//继续layer上面的动画
-
(void)resumeLayer:(CALayer*)layer
{
CFTimeInterval pausedTime = [layer
timeOffset];
layer.speed = 1.0;
layer.timeOffset = 0.0;
layer.beginTime = 0.0;
CFTimeInterval timeSincePause = [layer
convertTime:CACurrentMediaTime() fromLayer:nil] - pausedTime;
layer.beginTime = timeSincePause;
}
转载,仅供参考,祝你愉快,满意请采纳。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询