[英]how to change navigation animation to left to right in swift 4?
我的應用程序中有一個導航欄,可以將導航更改為模態顯示,但是我希望當用戶轉到目標視圖控制器時,導航動畫從左到右
這是我在第一個視圖控制器中的代碼
@IBAction func showProfilePage(_ sender: UIBarButtonItem) {
self.performSegue(withIdentifier: "showprofile", sender: self)
}
我為此閱讀了蘋果網站,也使用了此功能
private func navigationController(_ navigationController: UINavigationController,
willShow viewController: ProfileViewController,
animated: Bool) {
}
但這不起作用,所以我應該怎么做才能從左到右更改導航動畫?
嘗試這個。
let storyBoard : UIStoryboard = UIStoryboard(name: "PatientCheckout", bundle:nil)
let controller = storyBoard.instantiateViewController(withIdentifier: "PatientCheckoutViewController") as UIViewController
let transition = CATransition.init()
transition.duration = 0.45
transition.timingFunction = CAMediaTimingFunction.init(name: kCAMediaTimingFunctionDefault)
transition.type = kCATransitionPush //Transition you want like Push, Reveal
transition.subtype = kCATransitionFromLeft // Direction like Left to Right, Right to Left
transition.delegate = self
view.window!.layer.add(transition, forKey: kCATransition)
self.navigationController?.pushViewController(controller, animated: true)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.