iOS应用程序中的LTR到RTL [不关闭应用程序]

时间:2017-03-27 11:38:19

标签: right-to-left arabic-support

在应用程序中更改语言时,我需要根据所选语言更改应用程序布局。

例如,基本语言是英语;当用户将其更改为阿拉伯语时,我需要根据RTL更改UI。

在storyboard或ViewController中是否有用于实现LTR和RTL的特定设置?

1 个答案:

答案 0 :(得分:1)

管理RTL和LTR而不关闭应用程序Swift 3.0。

<强> // RTL

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

// applicationNavigationController是Application Default Navigation Controller             如果让applicationNavigationController = storyboard?.instantiateViewController(withIdentifier:&#34; root&#34;){                 UIApplication.shared.keyWindow?.rootViewController = applicationNavigationController

<强> LTR //

UIView.appearance()。semanticContentAttribute = .forceLeftToRight             UINavigationBar.appearance()。semanticContentAttribute = .forceLeftToRight            如果让applicationNavigationController = storyboard?.instantiateViewController(withIdentifier:&#34; root&#34;){             UIApplication.shared.keyWindow?.rootViewController = applicationNavigationController

//与MMDrawer达成交易时的其他提示。

<强>的AppDelegate

var centerContainer:MMDrawerController?

在一个ViewController中实现MMDrawer代码。

让appdelegate = UIApplication.shared.delegate为!的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)