Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UITextField wrong rtl alignment with latest version #61

Open
rami965 opened this issue Jan 27, 2021 · 5 comments
Open

UITextField wrong rtl alignment with latest version #61

rami965 opened this issue Jan 27, 2021 · 5 comments
Labels

Comments

@rami965
Copy link

rami965 commented Jan 27, 2021

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.

@MahmoudZinji
Copy link

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

@sam961
Copy link

sam961 commented Mar 30, 2021

sam here

@Abedalkareem
Copy link
Owner

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
Copy link
Author

rami965 commented May 18, 2021

@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
Copy link

Gargo commented Nov 11, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants