Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change presentViewController Transition animation

Tags:

I'm using presentViewController to change from a view to another without Navigation Controller like:

let HomeView = self.storyboard!.instantiateViewControllerWithIdentifier("HomeView") as! ViewControllerHome self.presentViewController(HomeView, animated:true, completion: nil) 

How to change the transition? I want to the same animation like the Navigation controller.

I can use another transitions, but I don't find the transition I want here is the code I'm using

let HomeView = self.storyboard!.instantiateViewControllerWithIdentifier("HomeView") as! ViewControllerHome HomeView.modalTransitionStyle = UIModalTransitionStyle.PartialCurl self.presentViewController(HomeView, animated:true, completion: nil) 
like image 739
Stranger B. Avatar asked Aug 17 '15 09:08

Stranger B.


People also ask

What is transitional animation?

Transitions are animations used to keep users oriented during user interface (UI) state changes and object manipulations, and make those changes feel smooth instead of jarring.


1 Answers

The answer of Mehul is correct but you can also do it the way you want it. With the instantiateViewController(withIndentifier: string)

This is how I do it:

let destController = self.storyboard?.instantiateViewController(withIdentifier: "") as! YourViewController destController.modalTransitionStyle = .flipHorizontal self.navigationController?.present(destController, animated: true, completion: nil)  // OR  let destController = self.storyboard?.instantiateViewController(withIdentifier: "") as! YourViewController destController.modalTransitionStyle = .flipHorizontal self.present(destController, animated: true, completion: nil)   
like image 200
Mar-k Avatar answered Nov 17 '22 13:11

Mar-k