我为CALayer
设置阴影路径的动画。动画CALayer阴影路径
框架调整正确,但阴影不缩放。
反而影子开始在最终大小CGSize(20,20)
和整个动画持有,即使我的shadowPath设置为初始值
[CATransaction begin];
[CATransaction setAnimationDuration: 0];
[CATransaction setDisableActions: TRUE];
layer.frame = CGRectMake(0,0,10,10);
layer.shadowPath = [UIBezierPath bezierPathWithRect:layer.bounds].CGPath;
[CATransaction commit];
[CATransaction begin];
[CATransaction setValue:[NSNumber numberWithFloat:10] forKey:kCATransactionAnimationDuration];
layer.frame = CGRectMake(0,0,20,20);
layer.shadowPath = [UIBezierPath bezierPathWithRect:tile.bounds].CGPath;
[CATransaction commit];
感谢您的努力。你能告诉我为什么我的解决方案不起作用吗?为什么你可以为框架设置动画而不是阴影路径? – prostock 2012-08-12 05:34:19
影子动画的要点是将'animationWithKeyPath'设置为'@“shadowPath”'。这意味着动画的对象是'shadowPath'。我也不知道这种机制,但设置'animationWithKeyPath'对于制作动画非常重要。这个可以吗 ? – weed 2012-08-12 05:47:56