NaveedUlHassan5
NaveedUlHassan5

Reputation: 265

UIButton semanticContentAttribute property is forced RTL in Localization

I'm working on an app which supports two languages(English & Arabic). I have a loginCViewController in which I have a UIButton and UITextField. When I switch to Arabic, my UIButton semanticContentAttribute is forced RightToLeft which I don't want.

Arabic

enter image description here

English

enter image description here

This is what I have tried so far, but My UIButton still changes it's semanticContentAttribute from RightToLeft when switched to Arabic Language.

I want my loginViewController to look same for both languages.

override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        numberButton.semanticContentAttribute = .forceLeftToRight
    }

I even tried it in viewDidLayoutSubviews() but still, same results.

override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        numberButton.semanticContentAttribute = .forceLeftToRight
    }

Any help regarding this would be highly appreciated.

Upvotes: 1

Views: 415

Answers (1)

Vipin Pareek
Vipin Pareek

Reputation: 246

hey may be this code will help you because it's working for me.

   UIView.appearance().semanticContentAttribute = .forceLeftToRight
   let window = self.view.superview
   self.view.removeFromSuperview()
   window?.addSubview(self.view)

Upvotes: 2

Related Questions