how to remove semanticContentAttribute when presenting a view controller

Viewed 501

My application supports English and Arabic language. I am using UIView.appearance().semanticContentAttribute property to change between RTL to LTR and vice versa as below.

 if selectedLanguageId == "eng"{
     UIView.appearance().semanticContentAttribute = .forceLeftToRight
 }else{
     UIView.appearance().semanticContentAttribute = .forceRightToLef
 }

I am presenting calendar event EKEventEditViewController() using self.present(eventController, animated: true, completion: nil). I wanted show this screen always LTR.

I have tried with following code, but it is shown as RTL when i change language to Arabic.

let eventController = EKEventEditViewController()
eventController.editViewDelegate = self
eventController.event = event
eventController.eventStore = self.eventStore
eventController.view.semanticContentAttribute = .forceLeftToRight
self.present(eventController, animated: true, completion: nil)

Please help me out to present this view always LTR.

wi

1 Answers

Do

UIView.appearance().semanticContentAttribute = .forceRightToLeft
self.present(eventController, animated: true, completion: nil)

and when you dismiss it do

if selectedLanguageId == "eng"{
   UIView.appearance().semanticContentAttribute = .forceLeftToRight
 }else{
  UIView.appearance().semanticContentAttribute = .forceRightToLeft
}
Related