I am using presentViewController to present new screen
let dashboardWorkout = DashboardWorkoutViewController()
presentViewController(dashboardWorkout, anima
class AA: UIViewController
func goToBB {
let bb = .. instantiateViewcontroller, storyboard etc .. as! AlreadyOnboardLogin
let tr = CATransition()
tr.duration = 0.25
tr.type = kCATransitionMoveIn // use "MoveIn" here
tr.subtype = kCATransitionFromRight
view.window!.layer.add(tr, forKey: kCATransition)
present(bb, animated: false)
bb.delegate, etc = set any other needed values
}
and then ...
func dismissingBB() {
let tr = CATransition()
tr.duration = 0.25
tr.type = kCATransitionReveal // use "Reveal" here
tr.subtype = kCATransitionFromLeft
view.window!.layer.add(tr, forKey: kCATransition)
dismiss(self) .. or dismiss(bb), or whatever
}
CATransition is not really made for doing this job.
Note you will get the annoying cross fade to black which unfortunately ruins the effect.
Many devs (like me) really don't like using NavigationController. Often, it is more flexible to just present in an ad-hoc manner as you go, particularly for unusual and complex apps. However, it's not difficult to "add" a nav controller.
simply on storyboard, go to the entry VC and click "embed -> in nav controller". Really that's it. Or,
in didFinishLaunchingWithOptions it's easy to build your nav controller if you prefer
you really don't even need to keep the variable anywhere, as .navigationController is always available as a property - easy.
Really, once you have a navigationController, it's trivial to do transitions between screens,
let nextScreen = instantiateViewController etc as! NextScreen
navigationController?
.pushViewController(nextScreen, animated: true)
and you can pop.
(The old one slides off at a lower speed, as the new one slides on.)
Generally and surprisingly, you usually have to make the effort to do a full custom transition.
Even if you just want the simplest, most common, move-over/move-off transition, you do have to do a full custom transition.
Fortunately, to do that there's some cut and paste boilerplate code on this QA... https://stackoverflow.com/a/48081504/294884 . Happy new year 2018!