/** 当前时间2秒以后开始动画 */ keyFrameAnim.beginTime = CACurrentMediaTime() + 2; /** 截止到当前时间,动画已经执行了2秒, 注意,如果执行的时间大于动画时长,则表示动画已经执行过。 */ keyFrameAnim.beginTime = CACurrentMediaTime() - 2;
/** The receiver does not appear until it begins and is removed from the presentation when it is completed. */ kCAFillModeRemoved; // (默认)动画模型的呈现效果直至开始时才显示,并在动画结束后移除。 /** The receiver does not appear until it begins but remains visible in its final state when it is completed. */ kCAFillModeForwards; // 动画模型的呈现效果直至开始时才显示,但在动画结束后仍然显示最后的状态。 /** The receiver appears in its initial state before it begins but is removed from the presentation when it is completed. */ kCAFillModeBackwards; // 动画开始之前,动画模型显示其初始呈现效果,但在动画结束后移除。 /** The receiver appears in its initial state before it begins and remains visible in its final state when it is completed. */ kCAFillModeBoth; // 动画开始之前,动画模型显示其初始呈现效果,并且在动画结束后仍然显示最后的状态。
- (IBAction)pauseBtnClicked:(id)sender {
/**
判断当前图层对象是否有针对postion属性的动画效果
*/
if ([self.layer.presentationLayer animationForKey:@"position"]) {
// 通过绝对时间获取图层的本地时间
CFTimeInterval localTime = [self.layer convertTime:CACurrentMediaTime() fromLayer:nil];
/**
将图层的时间流逝速度设置为0,以暂停动画
*/
self.layer.speed = 0;
// 设置图层的时间轴偏移量,为继续动画做准备
self.layer.timeOffset = localTime;
}
}
- (IBAction)continueBtnClicked:(id)sender {
/**
判断当前图层对象是否有针对postion属性的动画效果
*/
if ([self.layer.presentationLayer animationForKey:@"position"]) {
// 获取上次暂停时的时间轴偏移量
CFTimeInterval timeOffset = self.layer.timeOffset;
// 重置时间轴偏移量
self.layer.timeOffset = 0;
// 速度还原为1
self.layer.speed = 1;
// 重置开始时间
#warning 此处严重不理解。
self.layer.beginTime = 0;
// 计算暂停时间和当前时间的差值
CFTimeInterval localTime = [self.layer convertTime:CACurrentMediaTime() fromLayer:nil];
CFTimeInterval timeSincePause = localTime - timeOffset;
// 从上一次暂停处开始
self.layer.beginTime = timeSincePause;
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有