Custom Animations while changing RootViewcontroller

258 Views Asked by At

on the very first launch of my app i wanna show a Specific View Controller say firstLaunchVC and for that i'm doing this

in my didFinishLaunchingWithOptions

if (itsFirstLaunch){
     self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
    let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
    var initialViewController: UIViewController
    initialViewController = mainStoryboard.instantiateViewControllerWithIdentifier("SignupViewController") as! SignupViewController 

    self.window?.rootViewController = initialViewController

    self.window?.makeKeyAndVisible()
}

its working fine but now after completing my signup i want to change my RootViewController to my default ViewController say DefaultVC

appDelegate.window = UIWindow(frame: UIScreen.mainScreen().bounds)
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
var initialViewController: UIViewController
initialViewController = mainStoryboard.instantiateViewControllerWithIdentifier("DefaultVC") as! UITabBarController 
UIView.transitionWithView(self.appDelegate.window!, duration: 0.3, options: .TransitionFlipFromBottom, animations: {() -> Void in

    self.appDelegate.window?.rootViewController = initialViewController
    self.appDelegate.window?.makeKeyAndVisible()
    }, completion: { _ in }
)

its working fine and you can also see that i added animation in this Transition

 UIView.transitionWithView(self.appDelegate.window!, duration: 0.3, options: .TransitionFlipFromBottom, animations: {()....

but this animation is not good enough also here we have a lot of options like :

TransitionFlipFromLeft
TransitionFlipFromRight
TransitionCurlUp
TransitionCurlDown
TransitionCrossDissolve
TransitionFlipFromTop
TransitionFlipFromBottom etc...

but none of them are meeting my requirements (the are totally hideous) what i want is the Animation when a ViewController being dismissed i want to slide out the vc from the frame in a direction if anybody can guide me how to do this then it'll be so helpful for me

0

There are 0 best solutions below