I'm trying to have a right segue from two view controllers and the problem is that when it makes the transition, the first view controller makes the segue but it seems to glitch almost overlap itself for a quick second, and then place the new view controller on it. I have looked at other posts online and nobody seems to have this problem.
class UIStoryboardSegueFromRight: UIStoryboardSegue
{
override func perform() {
let src = self.source as UIViewController
let dst = self.destination as UIViewController
let transition: CATransition = CATransition()
let timeFunc: CAMediaTimingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
transition.duration = 0.2
transition.timingFunction = timeFunc
transition.type = kCATransitionPush
transition.subtype = kCATransitionFromRight
src.view.window?.layer.add(transition, forKey: nil)
src.present(dst, animated: false, completion: nil)
}
}
I have included the route in the images below. The source is using a UINavController that has a root controller that is a TabViewController. That TabViewController is then attached to a UIViewController which is the controller that is making the segue call with the custom transition shown on the very right of the picture.
All_Feed ViewController which is the source
The destination is just a UIViewController shown in the link below.
I'm not very familiar with this method of transitioning between view controllers. Have you tried using UIViewControllerAnimatedTransitioning
? https://developer.apple.com/documentation/uikit/uiviewcontrolleranimatedtransitioning
This would also let you abstract the logic in a more reusable way than doing it inside of a segue.
Since you want the source to present the destination, you would make your destination VC the transitioning delegate in order to hook up UIViewControllerAnimatedTransitioning logic
Since you haven't shared any visuals I'm not going to try to translate the animation you are trying to accomplish but maybe this tutorial can also help you understand how to implement the transition this way: https://www.objc.io/issues/5-ios7/view-controller-transitions/