2011-11-06 32 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'应该足够了。 –

相关问题