我有一个问题CAAnimationGroup
。我有一个名为的视图animeView
,我想同时应用围绕 Y 轴的 3D 旋转和缩放变换。旋转和缩放动画分别工作得非常好!但是当我将它们添加到CAAnimationGroup
非动画中时!
问题是什么?
CAKeyframeAnimation *rotation = [CAKeyframeAnimation animation];
CATransform3D rotationTransform = CATransform3DMakeRotation(M_PI, 0.0f, 1.0f, 0.0f);
rotationTransform.m34 = 1.0 / -500;
rotation.values = [NSArray arrayWithObjects:
[NSValue valueWithCATransform3D:CATransform3DMakeRotation(0.0f, 0.0f, 1.0f, 0.0f)],
[NSValue valueWithCATransform3D:rotationTransform],
[NSValue valueWithCATransform3D:CATransform3DMakeRotation(2.0*M_PI, 0.0f, 1.0f, 0.0f)] ,nil];
CAKeyframeAnimation *trans = [CAKeyframeAnimation animation];
trans.values = [NSArray arrayWithObjects:[NSValue valueWithCATransform3D:CATransform3DIdentity],[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.5, 0.5, 0.5)],[NSValue valueWithCATransform3D:CATransform3DIdentity], nil];
CAAnimationGroup *group = [CAAnimationGroup animation];
group.delegate = self;
[group setAnimations: [NSArray arrayWithObjects:rotation, trans, nil]];
group.duration = 2;
group.repeatCount = 3;
[self.animView.layer addAnimation:group forKey:nil];