Restore pre-iOS7 UINavigationController pushViewController animation

前端 未结 10 2317
终归单人心
终归单人心 2020-11-30 21:14

So. Just started transitioning my IOS code to IOS7, and ran into a bit of problem.

I\'ve got a UINavigationController, which has child ViewControllers a

10条回答
  •  粉色の甜心
    2020-11-30 22:09

    Swift 5 implementation of Arne's answer:

    extension UINavigationController {
      func pushViewControllerLegacyTransition(_ viewController: UIViewController) {
        let transition = CATransition()
        transition.duration = 0.25
        transition.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut)
        transition.type = .push
        transition.subtype = .fromRight
        view.layer.add(transition, forKey: nil)
        pushViewController(viewController, animated: false)
      }
    
      func popViewControllerLegacyTransition() {
        let transition = CATransition()
        transition.duration = 0.25
        transition.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut)
        transition.type = .push
        transition.subtype = .fromLeft
        view.layer.add(transition, forKey: nil)
        popViewController(animated: false)
      }
    }
    

提交回复
热议问题