Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS: Determine if device language is Right to Left (RTL)

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

like image 355
BarrettJ Avatar asked Jul 05 '12 20:07

BarrettJ


1 Answers

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     } } 

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

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

like image 87
Evgenii Avatar answered Oct 11 '22 04:10

Evgenii