Iphone 新的CATTransferM3DMakeRotation删除旧的转换?

Iphone 新的CATTransferM3DMakeRotation删除旧的转换?,iphone,cocoa-touch,core-animation,Iphone,Cocoa Touch,Core Animation,我在图层中添加了一个CATTransferorM3dMakeRotation。当我添加另一个时,它会删除旧的吗 第一个: [UIView beginAnimations:@"rotaty" context:nil]; [UIView setAnimationDuration:0.5]; [UIView setAnimationDelegate:self]; CGAffineTransform transform = CGAffineTransformMakeRotation(-3.14); k

我在图层中添加了一个
CATTransferorM3dMakeRotation
。当我添加另一个时,它会删除旧的吗

第一个:

[UIView beginAnimations:@"rotaty" context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelegate:self]; 
CGAffineTransform transform = CGAffineTransformMakeRotation(-3.14);
kuvert.transform = CGAffineTransformRotate(transform, DegreesToRadians(134));
kuvert.center = CGPointMake(kuvert.center.x-70, kuvert.center.y+100);
[UIView commitAnimations];
第二个:

CABasicAnimation *topAnim = [CABasicAnimation animationWithKeyPath:@"transform"];
topAnim.duration=1;
topAnim.repeatCount=0;
topAnim.fromValue = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(0.0, 0, 0, 0)];
float f = DegreesToRadians(180);  // -M_PI/1;
topAnim.toValue=[NSValue valueWithCATransform3D:CATransform3DMakeRotation(f, 0,1, 0)];
topAnim.delegate = self;
topAnim.removedOnCompletion = NO;
topAnim.fillMode = kCAFillModeBoth;
[topAnim setValue:@"flippy" forKey:@"AnimationName"];
[[KuvertLasche layer] addAnimation:topAnim forKey:@"flippy"];

第二个将重置视图,并在此之后应用自身。如何修复此问题?

是的,
CATTransferorM3dMakeRotation()
将创建一个全新的转换,该转换将覆盖现有转换。如果要修改现有转换,应使用
CATTransferorM3dRotate()
。例如,您可以使用以下行修改第二个代码示例

CATransform3D existingTransform = [[KuvertLasche layer] transform];
topAnim.fromValue = [NSValue valueWithCATransform3D:existingTransform];
float f = DegreesToRadians(180);  // -M_PI/1;
topAnim.toValue=[NSValue valueWithCATransform3D:CATransform3DRotate(existingTransform, f, 0,1, 0)];
请注意,如果一个动画要在另一个动画之后执行,则需要在第一个动画完成后使用代理回调来启动第二个动画。动画是在背景线程上执行的,因此,如果上面定义的两个动画一个接一个地被触发,结果可能会一团糟