Abedalkareem / LanguageManager-iOS

A Language manager to handle changing app language without restarting the app. It supports iOS and tvOS.
MIT License
393 stars 66 forks source link

UITextField wrong rtl alignment with latest version #61

Open rami965 opened 3 years ago

rami965 commented 3 years ago

Here is a screenshot for the representing the issue: Simulator Screen Shot - iPhone X - 2021-01-27 at 16 40 49

What I tried:

Note that I'm using a navigation controller and the rtl is working fine except for text fields.

MahmoudZinji commented 3 years ago

I have same issue, did you find a solution for this ?

sam961 commented 3 years ago

sam here

Abedalkareem commented 3 years ago

I'm trying to think of a solution, but until I find a solution, you can handle that in your BaseTextField by doing something like this:

 func updateTextAligment() {
  if(isRightToLeft) {
    self.textAlignment = .left
  } else {
    self.textAlignment = .right
  }
}
rami965 commented 3 years ago

@Abedalkareem This is my solution if it helps: I added an extension for NSTextAlignment

import LanguageManager_iOS

extension NSTextAlignment {
    static var defaultAlignment: NSTextAlignment {
        return LanguageManager.shared.currentLanguage == .ar ? .right : .left
    }
}

Usage

myTextField.textAlignment = .defaultAlignment
Gargo commented 10 months ago

@rami965 why everyone thinks that Arabic is the single language with RTL?