Search code examples
swiftxcodenavigationsegueuistoryboardsegue

Segue From Right To Left Without Push Or Presenting ViewController


Is there any possibilities to perform segue from Right To Left Without push or Persenting ViewController. The Following Code Working Fine with animation but if I use this class my TabBar is hidden. If I remove the code inside the Perform() TabBar is show but the animation is stop Using MDCBottomNavigationBar

class SegueFromRight: UIStoryboardSegue {
    override func perform() {
        let src = self.source
        let dst = self.destination
        src.view.superview?.insertSubview(dst.view, aboveSubview: src.view)

        dst.view.transform = CGAffineTransform(translationX: src.view.frame.size.width, y: 0)

        UIView.animate(withDuration: 0.25,delay: 0.0,options: UIView.AnimationOptions.curveEaseInOut,animations: {
            dst.view.transform = CGAffineTransform(translationX: 0, y: 0)
        },completion: { finished in
            src.navigationController?.pushViewController(dst, animated: false)
        }
        )
    }
}

is there any other way to perform segue with animation without hiding TabBar ?


Solution

  • Finally I found the answer. Just Removing the line Push ViewController

    class SegueFromRight: UIStoryboardSegue {
        override func perform() {
            let src = self.source
            let dst = self.destination
            src.view.superview?.insertSubview(dst.view, aboveSubview: src.view)
    
            dst.view.transform = CGAffineTransform(translationX: src.view.frame.size.width, y: 0)
    
            UIView.animate(withDuration: 0.25,delay: 0.0,options: UIView.AnimationOptions.curveEaseInOut,animations: {
                dst.view.transform = CGAffineTransform(translationX: 0, y: 0)
            },completion: { finished in
                //Remove Following line if you want to segue modally  
                //src.navigationController?.pushViewController(dst, animated: false)
            }
            )
        }
    }