How to change the Push and Pop animations in a navigation based app
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
UINavigationController gives you the standard push and pop animation automatically, but it also lets you replace that transition with your own animator. The clean way to do it is to assign a delegate to the navigation controller and return a UIViewControllerAnimatedTransitioning object for push and pop operations.
The Core Mechanism
A custom navigation transition involves two moving pieces:
- an animator object that knows how to animate from one view controller to another
- a navigation controller delegate that returns that animator for
.pushor.pop
The animator decides the duration and the actual movement of views inside the transition container.
Build a Simple Slide Animator
The example below uses Swift and creates a horizontal slide animation. It supports both push and pop based on an operation property.
This is intentionally simple, but it shows the correct structure.
Return the Animator From the Navigation Delegate
Set a delegate on the navigation controller and return the animator that matches the requested operation.
Then wire it up, usually in your root controller or scene setup:
The strong reference to navDelegate matters. If you create it as a temporary local object, the custom animation stops working when it gets deallocated.
Add Interaction Later if Needed
A custom push or pop animation does not automatically give you interactive gestures. If you want a drag-driven pop, you also need a UIPercentDrivenInteractiveTransition and delegate methods that provide an interaction controller.
You do not need that for basic animation replacement. Start with a non-interactive animator first and add gesture-driven interaction only if the design truly needs it.
Match the Animation to Navigation Semantics
Push transitions should feel like moving forward in hierarchy. Pop transitions should feel like reversing that motion. If the custom animation breaks that mental model, the interface becomes harder to use even if the animation looks impressive.
A few good rules:
- keep the duration short, usually around
0.25to0.4seconds - preserve directional consistency between push and pop
- avoid large 3D effects unless they support the product's visual language
In other words, custom transitions should clarify navigation, not compete with it.
Objective-C Projects Use the Same Pattern
If the app is older and still uses Objective-C, the architecture is the same. The syntax changes, but the delegate and animator roles are identical. That is useful if you are working on a legacy navigation-based app created from older Xcode templates.
When the Built-In Animation Is Better
Not every navigation flow should be customized. The system push and pop animations are already familiar to users and integrate well with the standard back gesture. If your new animation does not improve clarity, keeping the default transition is often the better engineering decision.
Use custom transitions when there is a concrete benefit, such as matching a card-style hierarchy or emphasizing a media browsing flow.
Common Pitfalls
Assigning the navigation delegate to a temporary object. The delegate must stay alive for the transition to work.
Forgetting to call completeTransition. That leaves the navigation controller in a broken state.
Animating the wrong views. Use the transition context's container view and the .from and .to views it provides.
Making push and pop feel unrelated. The user should be able to tell that pop is the reverse of push.
Overriding the system animation without considering the back-swipe gesture and general usability.
Summary
- Customize push and pop by providing a
UIViewControllerAnimatedTransitioningobject. - Return that animator from
UINavigationControllerDelegate. - Keep the delegate alive with a strong reference.
- Make the pop animation feel like the reverse of push.
- Use custom transitions only when they improve navigation clarity, not just appearance.

