1
votes

When changing language within the application I need to change the application layout as per selected language.

For example, the base language is English; when the user changes it to Arabic I need to change UI as per RTL.

Is there any specific setting in storyboard or in ViewController for achieving LTR and RTL?

1

1 Answers

2
votes

To Manage RTL and LTR without closing application Swift 3.0.

//RTL

UIView.appearance().semanticContentAttribute = .forceRightToLeft UINavigationBar.appearance().semanticContentAttribute = .forceRightToLeft

//applicationNavigationController is Application Default Navigation Controller if let applicationNavigationController = storyboard?.instantiateViewController(withIdentifier: "root") { UIApplication.shared.keyWindow?.rootViewController = applicationNavigationController

LTR//

UIView.appearance().semanticContentAttribute = .forceLeftToRight UINavigationBar.appearance().semanticContentAttribute = .forceLeftToRight if let applicationNavigationController = storyboard?.instantiateViewController(withIdentifier: "root") { UIApplication.shared.keyWindow?.rootViewController = applicationNavigationController

// Additional Tips while a deal with MMDrawer.

AppDelegate

var centerContainer:MMDrawerController?

Implement MMDrawer Code inside one ViewController.

let appdelegate=UIApplication.shared.delegate as! AppDelegate

    let mainStoryboard:UIStoryboard=UIStoryboard(name: "Main", bundle: nil)

    let centerViewController = mainStoryboard.instantiateViewController(withIdentifier: "HomeViewController") as! HomeViewController
    let leftViewController = mainStoryboard.instantiateViewController(withIdentifier: "LeftSideMenuViewController") as! LeftSideMenuViewController



    let leftSideNav = UINavigationController(rootViewController: leftViewController)
    let centerNav = UINavigationController(rootViewController: centerViewController)


    appdelegate.centerContainer = MMDrawerController(center: centerNav, leftDrawerViewController: leftSideNav)

    appdelegate.centerContainer?.maximumLeftDrawerWidth = 250.0


    appdelegate.centerContainer!.openDrawerGestureModeMask = MMOpenDrawerGestureMode.panningCenterView
    appdelegate.centerContainer!.closeDrawerGestureModeMask = MMCloseDrawerGestureMode.all

    //////////
    self.navigationController?.pushViewController(appdelegate.centerContainer!, animated: false)