本文介绍了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)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 08:56