Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/71.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 CABasicAnimation:如果CASHAPELEAR位置没有改变怎么办?_Ios_Cabasicanimation_Cashapelayer - Fatal编程技术网

Ios CABasicAnimation:如果CASHAPELEAR位置没有改变怎么办?

Ios CABasicAnimation:如果CASHAPELEAR位置没有改变怎么办?,ios,cabasicanimation,cashapelayer,Ios,Cabasicanimation,Cashapelayer,我对CABASICANITION这个话题真的很陌生。如果要设置x的动画 从当前x位置到您需要的特定x位置 使用以下命令: NSLog(@"CABasicAnimation now..."); CABasicAnimation *layerPositionAnimation = [CABasicAnimation animationWithKeyPath:@"position"]; [layerPositionAnimation setDuration:0.330];

我对CABASICANITION这个话题真的很陌生。如果要设置x的动画 从当前x位置到您需要的特定x位置 使用以下命令:

    NSLog(@"CABasicAnimation now...");
    CABasicAnimation *layerPositionAnimation = [CABasicAnimation animationWithKeyPath:@"position"];
    [layerPositionAnimation setDuration:0.330];
    [layerPositionAnimation setRemovedOnCompletion: NO];
    [layerPositionAnimation setFillMode: kCAFillModeForwards];
    [layerPositionAnimation setTimingFunction: [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];
    [layerPositionAnimation setFromValue:[NSValue valueWithCGPoint:CGPointMake(self.shapeLayer.position.x, self.shapeLayer.position.y)]];
    [layerPositionAnimation setToValue:[NSValue valueWithCGPoint:CGPointMake(14.0, self.shapeLayer.position.y)]];
    [self.shapeLayer addAnimation:layerPositionAnimation forKey:@"layerPositionAnimation"];
在我的例子中,self.shapeLayer是一个用作简单遮罩的CAShapeLayer:

    [[overlayTopShadow layer] setMask:self.shapeLayer];  
但如果动画从未发生(x位置未更改),该怎么办?我在代码中做错了什么? 有什么建议、想法、例子吗


非常感谢

谢谢@MarkM我以前发现这个问题没有解决办法。你能多给点支持吗。作为关键路径的“位置”是正确的,对吗?我尝试设置UIImageView[overlayTopShadow layer]层的动画,它可以工作。但是为什么我不能为用作遮罩的shapelayer设置动画呢?我很确定我可以,但我错过了什么?注意:如果您的视图承载自定义层对象,即没有关联视图的层对象,则必须使用核心动画对其进行任何更改。这可能是你正在处理的问题。