Home Forums iOS Development Switch the root controller with an animation

This topic contains 3 replies, has 2 voices, and was last updated by  Michele 2 years ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #1660 Reply


    Damir Dizdarević from the comment section asked how to make the transition of the root view controller with an animation so that it appears smoothly. Here is how to do that very quickly.

    The actual code to change the root view controller is as follow:

    In order to animate it, we just need to call the transitionWithView API and move the statement above inside the animations block, as below:

    That’s it, feel free to change the duration and the animation options to fit your preferences 🙂

    • This topic was modified 2 years ago by  Malek. Reason: Improve formatting
    #1664 Reply

    Damir Dizdarevic

    thanks for your reply! I already tried this solution once. The problem with that is that UIViewAnimationOptions does not offer a animation type that looks like a modal (over full screen) segue that comes from the bottom. do you know how i could achieve something like this?

    #1665 Reply


    Sure that’s possible 🙂

    Remove the UIView animation block and change it simply with the following statement:
    appDelegate.window?.rootViewController?.presentViewController(appDelegate.tabBarController!, animated: true, completion: nil)

    The code above will present the tab bar controller modally and hence you will get that animation from the bottom as you want 🙂

    • This reply was modified 2 years ago by  Malek.
    #1669 Reply

    Damir Dizdarevic

    Thats what I was looking for 🙂
    thanks a lot

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: Switch the root controller with an animation
Your information: