iOS:确定设备语言是否为从右到左 (RTL)

标签 ios localization

有没有办法轻松确定设备设置的语言是否为从右到左 (RTL)?

最佳答案

在 iOS 9 中,可以确定每个单独 View 的当前方向。

if #available(iOS 9.0, *) {
  if UIView.userInterfaceLayoutDirection(
    for: myView.semanticContentAttribute) == .rightToLeft {

      // The view is shown in right-to-left mode right now.
  }
} else {
    // Use the previous technique
    if UIApplication.shared.userInterfaceLayoutDirection == .rightToLeft {

        // The app is in right-to-left mode
    }
}

这是在 iOS 9 中推荐的确定布局方向的方法。

WWDC 2015 视频 New UIKit Support for International User Interfaces . 31:20 分钟后。

关于iOS:确定设备语言是否为从右到左 (RTL),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11352342/

相关文章:

ios - 根据对象参数 UPDATED Swift 从提取中删除重复对象

ios - 为什么 audioRecorderDidFinishRecording 功能不起作用?

android - cocos2d-x本地化简体/繁体中文

python - Django naturaltime 本地化错误

android - android 和资源限定符中的 RTL 语言支持

ios - Tableview 不显示数据

ios - UITableViewController 内部 UINavigationController 和 UITabBarController 底部插入关闭

python - 本地化浮点符号

ios - 如何停止执行 PDFNet 操作?

localization - 在 Akeneo 2.1 中,如何获取事件区域设置的列表?