如何改变dismissViewController的转换方向?

时间:2016-02-02 16:33:59

标签: ios objective-c xcode

开展Objective-c视频项目。在视频播放器上,我有一个按钮,可以将用户返回到菜单屏幕。

在我的PlayerViewController.m中,我有:

- (IBAction)unloadPlayer:(id)sender
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

它可以工作,但它从上到下推动屏幕。我想做的是从左到右推进。怎么办呢?

谢谢!

2 个答案:

答案 0 :(得分:2)

您可以在关闭viewcontroller时使用自定义动画。 这将解决您的问题。

CATransition *transition = [CATransition animation];
transition.duration = 0.3;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromLeft;
[self.view.window.layer addAnimation:transition forKey:nil];
[self dismissViewControllerAnimated:NO completion:nil];

答案 1 :(得分:0)

Swift 2:

UIView.transitionWithView(self.view, duration: 0.325, options: UIViewAnimationOptions.CurveEaseInOut, animations: {

    // animation

    }, completion: { (finished: Bool) -> () in

    // completion

    })

但我建议使用它:

{{1}}