Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/121.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在卡巴斯基化结束时反弹_Ios_Objective C_Cabasicanimation - Fatal编程技术网

Ios 在卡巴斯基化结束时反弹

Ios 在卡巴斯基化结束时反弹,ios,objective-c,cabasicanimation,Ios,Objective C,Cabasicanimation,设置动画: CABasicAnimation *noteAnimation = [CABasicAnimation animation]; noteAnimation.keyPath = @"position.x"; noteAnimation.byValue = [NSNumber numberWithFloat:CGRectGetWidth(self.view.frame) - 50]; noteAnimation.duration = 1.f; noteAnimation.fillMode

设置动画:

CABasicAnimation *noteAnimation = [CABasicAnimation animation];
noteAnimation.keyPath = @"position.x";
noteAnimation.byValue = [NSNumber numberWithFloat:CGRectGetWidth(self.view.frame) - 50];
noteAnimation.duration = 1.f;
noteAnimation.fillMode = kCAFillModeBoth;
noteAnimation.removedOnCompletion = NO;
noteAnimation.autoreverses = YES;
noteAnimation.repeatCount = HUGE;
noteAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
[self.greenSquareView.layer addAnimation:noteAnimation forKey:@"noteAnimation"];
要暂停我使用的动作动画,请执行以下操作:

CFTimeInterval pausedTime = [view.layer convertTime:CACurrentMediaTime() fromLayer:nil];
view.layer.speed = 0.0;
view.layer.timeOffset = pausedTime;
但在本例中,视图停止反弹

完整的项目


你应该总是问一个问题。由于
speed
timeOffset
都不是可设置动画的属性,我将尝试
removeAllimations()
并将层的当前模型值设置为显示层的值(在本例中为位置)。你必须开始一个新的
CATransaction
,并使用
CATransaction禁用动画。setDisableActions(false)
,然后将位置与显示层同步,然后提交事务。我不想要动画
speed
timeOffset
(我在问题中添加了一些信息)。我使用此属性暂停动画。我尝试了你的方法-它不起作用(反弹复制的问题)。我下载了你的项目,它没有反弹就暂停了。首先:你在附加的gif上看到反弹了吗?(我从iphone上录制了这段视频)。我没有在模拟器中看到弹跳。但是在真实的设备(iPhone6,iOS10.1)上,这个“bug”重现了。是的,在gif上,我完全明白你的意思。下班后,我会尝试在真实的设备上复制。