hong developer
hong developer

Reputation: 13906

How to move to the slide when showing the screen

Now my screen is shown moving from bottom to top as Screen move. But I want to be seen moving from left to right. What can I do?

Current Move Sidebar Screen

    func openSidebarScreen(){
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let side = storyboard.instantiateViewController(withIdentifier: "SideMenuWebViewController") as! SideMenuWebViewController
        side.modalPresentationStyle = .overCurrentContext
        side.modalTransitionStyle = .crossDissolve
        side.delegate = self
        self.performSegue(withIdentifier: "open", sender: qrcodeScan)
    }

The direction I want the sidebar to open.

enter image description here

Upvotes: 1

Views: 80

Answers (1)

hong developer
hong developer

Reputation: 13906

  1. First, I applied basic animation using the navigation controller.

The default direction moves from right to left.

enter image description here

  1. Second, I modified the navigation controller's direction (RightToLeft)
    override func viewDidLoad() {
        super.viewDidLoad()
        navigationController?.view.semanticContentAttribute = .forceRightToLeft
        navigationController?.navigationBar.semanticContentAttribute = .forceRightToLeft
    }
  1. Thirdly, the screen is moved through navigation.
    func openSidebarScreen(){
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let side = storyboard.instantiateViewController(withIdentifier: "SideMenuWebViewController") as! SideMenuWebViewController
        side.modalPresentationStyle = .overCurrentContext
        side.modalTransitionStyle = .crossDissolve
        side.delegate = self
        self.navigationController?.pushViewController(side, animated: true)
    }

Upvotes: 1

Related Questions