2017-03-27 9 views
1

응용 프로그램에서 언어를 변경하면 선택한 언어에 따라 응용 프로그램 레이아웃을 변경해야합니다.iOS 응용 프로그램에서 LTR to RTL [응용 프로그램을 닫지 않고]

예를 들어, 기본 언어는 영어입니다. 사용자가 아랍어로 변경하면 RTL 당 UI를 변경해야합니다.

LTR 및 RTL을 달성하기 위해 스토리 보드 또는 ViewController에 특정 설정이 있습니까?

답변

0

응용 프로그램을 닫지 않고 RTL과 LTR을 관리하려면 Swift 3.0.

// RTL

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

// applicationNavigationController는 응용 프로그램의 기본 탐색 컨트롤러 경우입니다 applicationNavigationController = storyboard? .instantiateViewController (withIdentifier : "root") { UIApplication.shared.keyWindow ?rootViewController = applicationNavigationContr oller

LTR //

UIView.appearance() semanticContentAttribute = .forceLeftToRight UINavigationBar.appearance() semanticContentAttribute = .forceLeftToRight applicationNavigationController = 스토리 보드를 할 경우 .instantiateViewController (withIdentifier :..? "루트") { UIApplication.shared.keyWindow ?rootViewController = applicationNavigationController

// MMDrawer를 다루는 동안 추가 팁.

AppDelegate에

var에 centerContainer : MMDrawerController?

하나의 ViewController 내에 MMDrawer 코드를 구현하십시오.

let 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)