我正在尝试使用右下角的动画来更改我的rootViewController。
我知道如何用翻转动画做到这一点:
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let viewController = mainStoryboard.instantiateViewControllerWithIdentifier("LandingViewController")
UIView.transitionWithView( UIApplication.sharedApplication().keyWindow!,
duration: 0.5,
options: UIViewAnimationOptions.TransitionFlipFromLeft,
animations: { UIApplication.sharedApplication().keyWindow?.rootViewController = viewController; },
completion: nil)
但是,UIViewAnimationOptions没有从右侧滑动动画。 我怎样才能做到这一点?
答案 0 :(得分:0)
试试这个
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let viewController = mainStoryboard.instantiateViewControllerWithIdentifier("LandingViewController")
let navigationController = UIApplication.sharedApplication().keyWindow?.rootViewController.navigationController
//first push the viewController
navigationController?.pushViewController(viewController, animated: true)
然后,在viewController
的viewDidAppear,您应该执行此代码
//remove all previous controllers in the stack by settings viewControllers stack with only current viewController
self.navigationController?.viewControllers = [self]
我希望它有所帮助