Created
August 27, 2025 06:41
-
-
Save rqbctg/b5e86599034b092585f09ced6294f321 to your computer and use it in GitHub Desktop.
A Simple Yet Powerful RootNavigation Handler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: - Protocol for Root Changing | |
protocol RootChanging { | |
func changeRoot(to viewController: UIViewController, in navigationController: UINavigationController) | |
} | |
// MARK: - Concrete Root Changer | |
class AppRootChanger: RootChanging { | |
func changeRoot(to viewController: UIViewController, in navigationController: UINavigationController) { | |
let direction: CATransitionSubtype = .fromRight | |
let duration = 0.3 | |
let transition = CATransition() | |
transition.type = CATransitionType.push | |
transition.subtype = direction | |
transition.duration = duration | |
transition.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut) | |
navigationController.view.layer.add(transition, forKey: kCATransition) | |
navigationController.setViewControllers([viewController], animated: false) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment