나의 플랫폼/iOS

[iOS][Swift] NavigationController 화면 전환 시 애니메이션

GsBOB 2017. 5. 16. 10:37

## CATransition 이용

            let transition = CATransition()

            transition.duration = 0.3

            transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)

            transition.type = kCATransitionFade

            self.navigationController?.view.layer.add(transition, forKey: nil)

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




## UIView Aniamtion 이용

UIView.animate(withDuration: 0.5, animations: {

            UIView.setAnimationCurve(.easeInOut)

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

            UIView.setAnimationTransition( UIViewAnimationTransition.curlUp , for: (self.navigationController?.view)!, cache: false)

        })


참고하세요.