2011-11-06 64 views

回答

8

這是可能的,看看我用了一段時間後面的代碼,並嘗試使它爲自己工作。鬱可唯需要改變setAnimationTransition

[UIView beginAnimations:nil context:NULL]; 
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 
[UIView setAnimationDuration:0.75]; 
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO]; 
[UIView commitAnimations]; 

[UIView beginAnimations:nil context:NULL]; 
[UIView setAnimationDelay:0.375]; 
[self.navigationController popViewControllerAnimated:NO]; 
[UIView commitAnimations]; 

有幾種不同類型的默認動畫使用,蘋果網站說,這種動畫是可能的:

typedef enum { 
    UIViewAnimationTransitionNone, 
    UIViewAnimationTransitionFlipFromLeft, 
    UIViewAnimationTransitionFlipFromRight, 
    UIViewAnimationTransitionCurlUp, 
    UIViewAnimationTransitionCurlDown, 
} UIViewAnimationTransition; 

所以你的情況,你會想使用以下內容:

[UIView beginAnimations:nil context:nil]; 
    [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut]; 
    [UIView setAnimationDuration:0.75]; 
    [self.navigationController popViewControllerAnimated:NO]; 
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO]; 
    [UIView commitAnimations]; 
+0

謝謝。有沒有像滑動'pushViewController'一樣滑動它的方法? – Mason

+0

是的,就像我說的,你只需要改變這裏的線:[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO]; – Wesley

+0

我明白這一點。雖然我找不到正確的轉換。 – Mason

16

這是如何在相反方向彈出視圖控制器。它爲我工作100%

CATransition *transition = [CATransition animation]; 
    transition.duration = 0.45; 
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]; 
    transition.type = kCATransitionFromRight; 
    [transition setType:kCATransitionPush]; 
    transition.subtype = kCATransitionFromRight; 
    [self.navigationController.view.layer addAnimation:transition forKey:nil]; 
    [self.navigationController popViewControllerAnimated:NO]; 
+0

這就是我正在尋找的!謝謝。 – iChirag

+2

您將類型設置了兩次? 'transition.type = kCATransitionPush'應該足夠了。 –

相關問題