2011-08-21 17 views
0

我要翻轉,並使用動畫展開按鈕翻轉和規模擴大按鈕動畫

代碼:

[UIView beginAnimations:nil context:nil]; 
[UIView setAnimationDuration:5.0]; 
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:mybutton cache:YES]; 
[mybutton setFrame:CGRectMake(mybutton.frame.origin.x, mybutton.frame.origin.x, 200, 200)]; 
[UIView commitAnimations]; 

有這個動畫問題:
- 巴頓被翻轉,但它的半圓後擴大翻轉。
- 按鈕位置翻轉後不準確。

我該如何解決?

回答

0

嘗試完全評論setFrame,它應該翻轉得更好。也嘗試將緩存設置爲NO。根據文檔,你不應該修改在動畫本身過渡的視圖 - cache:NO會有所幫助,但它仍然是不正確的。

你通常有一個給setAnimationTransition函數的父視圖,然後在取出舊的子視圖並將其從子視圖中移除後,然後添加新的子視圖。這給出了一個孩子子視圖翻轉的幻覺,並且新孩子被翻轉爲焦點。轉換髮生在父項上,儘管包含子項。

無論哪種方式,請嘗試註釋setFrame一分鐘,它應該看起來更一致。

0

因爲它們都是獨立的動畫,你也可以嘗試使用,一旦動畫完成,其被稱爲AnimationDidStopSelector;)

哦順便說一句,在你CGRectMake您使用y座標的X軸再次協調,這可能就是爲什麼位置是不準確的^^

這樣類似的東西:

- (void)yourFunction { 
    [UIView beginAnimations:nil context:indexPath]; 
    [UIView setAnimationDuration:0.3]; 
    [UIView setAnimationDelegate:self]; 
    [UIView setAnimationDidStopSelector:@selector(functionEnded:finished:context:)]; 
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:mybutton cache:YES]; 
    [UIView commitAnimations]; 
} 

- (void)functionEnded:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context { 
     [UIView beginAnimations:nil context:indexPath]; 
     [UIView setAnimationDuration:1.3]; 
     [mybutton setFrame:CGRectMake(mybutton.frame.origin.x, mybutton.frame.origin.y, 200, 200)]; 
     [UIView commitAnimations]; 
} 
+0

我需要的按鈕,翻轉,並在同一時間擴大。 示例:在iPad上打開iTunes,然後單擊一首歌曲。 – Houranis