Push to one viewcontroller from right to left animation iOS swift

 Solution:

In my viewcontroller

            let vc = mainBoard.instantiateViewController(withIdentifier: "myvc") asmyvc

            self.changeVCWithAnimation(vc: vc)



extension UIViewController

    func changeVCWithAnimation(vc: UIViewController) {

        self.navigationController?.view.layer.add(getTransitionFromRight(), forKey: kCATransition)

        self.navigationController?.pushViewController(vc, animated: false)

    }


    func getTransitionFromRight() -> CATransition {

        return Transition.getTransition(timingFunction: CAMediaTimingFunction(name:CAMediaTimingFunctionName.easeInEaseOut),transitionType: CATransitionType.moveIn, transitionSubType: CATransitionSubtype.fromRight)

    }

    }


struct Transition {

    static func getTransition(timingFunction: CAMediaTimingFunction, transitionType: CATransitionType, transitionSubType: CATransitionSubtype) -> CATransition {

        let transition:CATransition = CATransition()

        transition.duration = 0.5

        transition.timingFunction = timingFunction

        transition.type = transitionType

        transition.subtype = transitionSubType

        return transition

    }

}

Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

Saved Image in document directory and save path in coredata not able to fetch the image file iOS swift