我有一个旋转的视图:
self.mainView.layer.transform = CATransform3DRotate(self.mainView.layer.transform, -M_PI / 2, 0, 0, 1);
我对其应用 CAKeyFrameAnimation :
CAKeyframeAnimation *bounceAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
bounceAnimation.fillMode = kCAFillModeBoth;
bounceAnimation.removedOnCompletion = YES;
bounceAnimation.duration = 0.4;
bounceAnimation.values = @[
//[NSValue valueWithCATransform3D:CATransform3DMakeRotation(-M_PI / 2.0f, 0.0f, 0.0f, 1.0f)]
[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.01f, 0.01f, 0.01f)],
[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.1f, 1.1f, 1.1f)],
[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.9f, 0.9f, 0.9f)],
[NSValue valueWithCATransform3D:CATransform3DIdentity]];
bounceAnimation.keyTimes = @[@0.0f, @0.5f, @0.75f, @1.0f];
bounceAnimation.timingFunctions = @[
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[self.mainView.layer addAnimation:bounceAnimation forKey:@"bounce"];
当我将视图附加到它的超级视图时,动画在我的初始旋转应用到它之前应用到视图,并且在动画完成之后,然后应用旋转。
我将如何制作它,以便在动画发生之前应用我发布的第一段代码的旋转?那么当view附加到它的superview时,就已经出现旋转了,然后进行动画呢?