2011-07-01 45 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

謝謝,這就像我最終做的事情 –