iOS:确定设备语言是否为从右到左 (RTL) [英] iOS: Determine if device language is Right to Left (RTL)

查看:18
本文介绍了iOS:确定设备语言是否为从右到左 (RTL)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Is there a way to easily determine if the language the device is set to is right to left (RTL)?

推荐答案

在 iOS 9 中,可以确定每个单独视图的当前方向.

In iOS 9 one can determine the current direction for each individual 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 中确定布局方向的推荐方法.

This is the recommended way of determining the layout direction in iOS 9.

WWDC 2015 视频对国际用户界面的新 UIKit 支持.31:20 分钟后.

WWDC 2015 video New UIKit Support for International User Interfaces. After minute 31:20.

这篇关于iOS:确定设备语言是否为从右到左 (RTL)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆