Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/97.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
Iphone UIView动画,变换层.shadowPath_Iphone_Ios - Fatal编程技术网

Iphone UIView动画,变换层.shadowPath

Iphone UIView动画,变换层.shadowPath,iphone,ios,Iphone,Ios,我创建了一个具有自定义阴影路径的UIImageView。该视图将在屏幕上左右移动,但我需要阴影路径进行与图像层本身不同的变换。这可能吗?当我执行以下操作时,移动图像本身会起作用,阴影也会移动: [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.3]; [UIView setAnimationCurve:UIViewAnimationCurveEaseOut]; im.center = locatio

我创建了一个具有自定义阴影路径的UIImageView。该视图将在屏幕上左右移动,但我需要阴影路径进行与图像层本身不同的变换。这可能吗?当我执行以下操作时,移动图像本身会起作用,阴影也会移动:

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
im.center = location;
[UIView commitAnimations];
但是,如果我尝试在“commitAnimations”之前添加一个层转换,阴影将立即呈现该属性,例如:

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
im.center = location;
im.layer.shadowPath = [self createPerspectiveShadow:im]; //this will not animate
[UIView commitAnimations];
所以,我的问题是,有没有办法在动画中重新计算阴影


谢谢
UIView
动画并不总是允许您设置
CALayer
属性的动画;尝试改用
cabasicanitation

您可以将CGPathREf传递给toValue

theAnimation.toValue = (id)[UIBezierPath bezierPathWithRect:newRect].CGPath;

请参见

不幸的是,CABasicAnimation可能无法剪切它,因为我必须重新计算整个阴影路径。CABasicAnimation.fromValue和.toValue需要NSNumber,我无法将CGPathRef传递给它们。有什么我遗漏的吗?嗯,这很难。您最好设置一个
NSTimer
每1/60秒触发一次,然后通过编程更新阴影的位置。很糟糕,但它会起作用……我担心会出现这种情况:)哦,好吧,我希望有一个更快、更简单的解决方案。无论如何,感谢您的输入Jeff(我会在一两天内标记您的答案…)有点晚了,但您肯定可以使用CABASICANIATION设置路径动画
fromValue
toValue
id
,所以只需在
CGPathRef
上执行
(\uu桥id)