有没有办法轻松确定设备设置的语言是否为从右到左 (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/