结合UIView和subiview的CALayer上的动画?

时间:2011-07-01 13:11:02

标签: iphone ios animation core-animation

我正在制作像这样的UIView转换:

UIView *areaView = areaController.view;
[areaController viewWillAppear:YES];

UIView *subView = self.customView.subView;
UIButton *button = customView.button; // button is a subview of customView.subView

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];

[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:subView cache:YES];

[button removeFromSuperview];
[subView addSubview:areaView];
[areaController viewDidAppear:YES];


[UIView commitAnimations];

[self.areaController start];  // areaController starts the animation of the CALayer, see below

这会从按钮“后面”翻转新视图,areaView就好了,但是在areaView中有另一个子视图,它正在动画它的CALayer:

CATransform3D rotate = CATransform3DMakeRotation(angle, 1, 0, 0);

CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform"];

animation.toValue = [NSValue valueWithCATransform3D:rotate];
animation.duration = .08;
animation.delegate = self;
animation.fillMode = kCAFillModeForwards;
animation.removedOnCompletion = NO;   

[layer addAnimation:animation forKey:@"transform"];

我的问题是:

如何让这些动画在平行中动画?

目前,CALayer上的动画在调用[self.areaController start];时启动,但在超级视图的转换完成之前,结果不可见。我应该以某种方式使用UIView层的动画组吗?

1 个答案:

答案 0 :(得分:0)

我认为你不能同时做到这些。你可以做的是使用CATransform3D做第一个动画,然后它们将同时发生。 这是一个老帖子,所以也许你已经解决了这个问题。