Skip to content

Commit

Permalink
Fixed the right to left ui issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali authored and Ali committed Aug 27, 2017
1 parent 109f5ee commit 3e90ca2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion TextFieldCounter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ open class TextFieldCounter: UITextField, UITextFieldDelegate {
if let currentFont : UIFont = font {
label.font = currentFont
label.textColor = counterColor
label.textAlignment = .left
label.textAlignment = label.userInterfaceLayoutDirection == .rightToLeft ? .right : .left
label.lineBreakMode = .byWordWrapping
label.numberOfLines = 1
}
Expand Down Expand Up @@ -258,4 +258,12 @@ extension UIView {
}, completion: nil)
}

var userInterfaceLayoutDirection: UIUserInterfaceLayoutDirection {
if #available(iOS 9.0, *) {
return UIView.userInterfaceLayoutDirection(for: self.semanticContentAttribute)
} else {
return UIApplication.shared.userInterfaceLayoutDirection
}
}

}

0 comments on commit 3e90ca2

Please sign in to comment.