如何用动画显示和隐藏UISplitViewController [英] how to show and hide UISplitViewController with animation

查看:234
本文介绍了如何用动画显示和隐藏UISplitViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序中当前窗口的 rootViewController MainViewController 。并且在另一个视图控制器中有一个按钮叫做 SubViewController ,如果用户单击按钮,我想显示 UISplitViewController 。我已经实现它如下:

The current rootViewController of window in my app is MainViewController. and there's a button in another view controller called SubViewController, I want to show UISplitViewController if a user click the button. I have implemented it as following:

//SubViewController.m
UISplitViewController *splitVC =[self splitVC];
self.view.window.rootViewController = splitVC;

没有动画可显示 splitVC 需要显示它与幻灯片样式,例如,滑动 SubViewController .view到右边显示 UISplitViewController 如果用户单击 UISplitViewController 上的按钮,以回退 SubViewController.view

there's no animation to show splitVC, I need to show it with slide style, example, to slide the SubViewController.view to right to show the UISplitViewController, and if the user click a button on UISplitViewController, to slide back the SubViewController.view

推荐答案

尝试这样:

AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
UISplitViewController *splitVC =[self splitVC];

[UIView transitionWithView:self.view.window
                  duration:0.5
                   options:UIViewAnimationOptionTransitionFlipFromLeft
                animations:^{
                    appDelegate.window.rootViewController = splitVC;
                }
                completion:^(BOOL finished){
                }];

您可以使用选项指定不同的动画类型参数

这篇关于如何用动画显示和隐藏UISplitViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆