2011-12-02 41 views
0

我需要在UIView上製作一個同時動畫。我想同時改變大小和位置。我試試這個代碼:UIView:一個動畫有多個變化

[UIView beginAnimations:nil context:nil]; 
[UIView setAnimationDuration:1.0]; 
[UIView setAnimationBeginsFromCurrentState:NO]; 

[openingElement setFrame:elementFrame]; 

[UIView commitAnimations]; 

此代碼的工作,但在UIView的兩步(移動和調整後)動畫,我想一起做吧。 是否可以製作一個具有多個變化的動畫?

回答

1

有可能使一個動畫的多重變化。在UIView上,您可以同時動畫變更alpha,bounds,frame,center,transform和backgroundColor。

如果幀屬性上的動畫有問題,請嘗試對中心和邊界進行動畫處理。

[UIView beginAnimations:nil context:nil]; 
[UIView setAnimationDuration:1.0]; 
[UIView setAnimationBeginsFromCurrentState:NO]; 

[openingElement setBounds:newBounds]; 
[openingElement setCenter:newCenter]; 

[UIView commitAnimations]; 
0

試試這個

[UIView setAnimationBeginsFromCurrentState:YES];