在应用程序中更改语言时,我需要根据所选语言更改应用程序布局。
例如,基础语言是英语;当用户将其更改为阿拉伯语时,我需要根据 RTL 更改 UI。
故事板或 ViewController 中是否有任何特定设置来实现 LTR 和 RTL?
在应用程序中更改语言时,我需要根据所选语言更改应用程序布局。
例如,基础语言是英语;当用户将其更改为阿拉伯语时,我需要根据 RTL 更改 UI。
故事板或 ViewController 中是否有任何特定设置来实现 LTR 和 RTL?
在不关闭应用程序 Swift 3.0 的情况下管理 RTL 和 LTR。
//RTL
UIView.appearance().semanticContentAttribute = .forceRightToLeft UINavigationBar.appearance().semanticContentAttribute = .forceRightToLeft
//applicationNavigationController 是应用程序默认导航控制器 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
// 处理 MMDrawer 时的附加提示。
应用委托
var centerContainer:MMDrawerController?
在一个 ViewController 中实现 MMDrawer 代码。
让 appdelegate=UIApplication.shared.delegate 为!应用委托
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)