2011-07-01 26 views
2

我动画一个UIView过渡,像这样:结合UIView和子视图的CALayer上的动画?

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"]; 

我的问题是:

怎样使这两个动画在parallell动画?

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

+0

我也想知道这个...... –

回答

0

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

+0

谢谢,这就像我最终做的事情 –