iOS Segue - Left to Right -

前端 未结 11 977
旧巷少年郎
旧巷少年郎 2020-11-30 20:40

I\'ve read the other posts on segues but none solve my question.

Simply put, my ViewControllers are ordered, like a book. I want backward transitions (

11条回答
  •  無奈伤痛
    2020-11-30 21:23

    Updated accepted answer in Swift 3:

    import UIKit
    
    class SegueFromLeft: 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: UIViewAnimationOptions.curveEaseInOut,
                animations: {
                    dst.view.transform = CGAffineTransform(translationX: 0, y: 0)
                },
                completion: { finished in
                    src.present(dst, animated: false, completion: nil)
                }
            )
        }
    }
    

提交回复
热议问题