Skip to content

Commit 4022206

Browse files
author
Oleg Montak
committed
Use effectiveUserInterfaceLayoutDirection
Use effectiveUserInterfaceLayoutDirection to detect RTL on iOS 10 and above. This is recommended approach to detect layout direction taking into account view's semantic content attribute, trait environment and UIApplication layout direction More info here: https://developer.apple.com/videos/play/wwdc2016/232/?time=1027
1 parent 3d651bb commit 4022206

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Sources/Extensions/UIView+PinLayout.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ extension UIView: Layoutable, SizeCalculable {
8080
public func isLTR() -> Bool {
8181
switch Pin.layoutDirection {
8282
case .auto:
83-
if #available(iOS 9.0, *) {
83+
if #available(iOS 10.0, tvOS 10.0, *) {
84+
return effectiveUserInterfaceLayoutDirection == .leftToRight
85+
} else if #available(iOS 9.0, *) {
8486
return UIView.userInterfaceLayoutDirection(for: semanticContentAttribute) == .leftToRight
8587
} else if let shared = UIApplication.value(forKey: "sharedApplication") as? UIApplication {
8688
return shared.userInterfaceLayoutDirection == .leftToRight

0 commit comments

Comments
 (0)