LanguageManager-iOS icon indicating copy to clipboard operation
LanguageManager-iOS copied to clipboard

UITextField wrong rtl alignment with latest version

Open rami965 opened this issue 3 years ago • 5 comments

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

What I tried:

  • Update to latest version 1.2.3
  • Install via cocoapods and carthage
  • Set Arabic as default language in AppDelegate
  • Setting the textfields alignment to natural
  • Remove the Arabic localization and add it again

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

rami965 avatar Jan 27 '21 16:01 rami965

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

MahmoudZinji avatar Mar 29 '21 10:03 MahmoudZinji

sam here

sam961 avatar Mar 30 '21 08:03 sam961

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

Abedalkareem avatar Apr 10 '21 04:04 Abedalkareem

@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

rami965 avatar May 18 '21 15:05 rami965

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

Gargo avatar Nov 11 '23 07:11 Gargo