简体   繁体   中英

Transition Animation without storyboard segue swift

I want to change animation when ViewController navigate to another ViewController. I am using storyboard but I am not creating Segue. Navigation done with storyboardID my code for navigation is:

let SB = UIStoryboard(name: "Main", bundle: nil)
let vc = SB.instantiateViewControllerWithIdentifier("StartRecordingView")
self.navigationController?.pushViewController(vc, animated: true)

Now I want to change transition animation during naivation. I searched lot but all solutions is for segue. Can anyone here help how to change animation.

You can do it by navigation controller delegate to modify behavior when a view controller is pushed or popped from the navigation stack of a UINavigationController object.

-navigationController:animationControllerForOperation:fromViewController:toViewController:

Declaration:

 - (id<UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController
                                      animationControllerForOperation:(UINavigationControllerOperation)operation
                                                   fromViewController:(UIViewController *)fromVC
                                                     toViewController:(UIViewController *)toVC

Refer this link : https://developer.apple.com/library/ios/documentation/UIKit/Reference/UINavigationControllerDelegate_Protocol/index.html#//apple_ref/occ/intfm/UINavigationControllerDelegate/navigationController:animationControllerForOperation:fromViewController:toViewController :

Example link : https://www.raywenderlich.com/86521/how-to-make-a-view-controller-transition-animation-like-in-the-ping-app

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM