Member-only story

Customize your navigation with Push using the present animation in iOS

Wing CHAN
3 min readSep 3, 2024

--

Purpose

Implement a custom navigation animation that uses a “present-like” animation effect during push and pop operations across multiple view controllers.

  1. A pushes B (normal animation)
  2. B pushes C (custom present-like animation)
  3. C pops back to B (custom dismiss-like animation)
  4. Multiple view controllers may push to C, all using the same custom animations

Steps

Step 1: Create Custom Animation Controllers

  1. PresentAnimationController: Handles the animation effect when pushing to ViewControllerC.
  2. DismissAnimationController: Handles the animation effect when popping back from ViewControllerC.
import Foundation
import UIKit

// PresentAnimationController: Custom "present-like" animation
class PresentAnimationController: NSObject, UIViewControllerAnimatedTransitioning {
func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
return 0.5 // Duration of the animation
}

func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
guard let fromVC =…

--

--

Wing CHAN
Wing CHAN

Written by Wing CHAN

Mobile Dev 📱 iOS, Flutter

No responses yet