How do I do a Fade/No transition between view controllers

前端 未结 10 773
时光取名叫无心
时光取名叫无心 2020-12-07 08:48

Is it possible to do a fade in and fade out transition between View Controllers in Storyboard. Or without transition.

If it\'s possible, what\'s the code for it?

10条回答
  •  心在旅途
    2020-12-07 09:21

    Try this one.

        let transition: CATransition = CATransition()
        transition.duration = 0.4
        transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
        transition.type = kCATransitionFade
        self.navigationController!.view.layer.addAnimation(transition, forKey: nil)
    
        let vc = self.storyboard?.instantiateViewControllerWithIdentifier("vcID") as! My_ViewController
        self.navigationController?.pushViewController(vc, animated: false)
    

提交回复
热议问题