UI hangs after changing semanticContentAttribute - ios

I have an application with two languages: Arabic & English. I would like to change UI direction after changing the language inside the app.
I use this code to do this:
UIView.appearance().semanticContentAttribute = isRTL ? .forceRightToLeft : .forceLeftToRight
This code is working well, I will get UI with the correct direction, but the app performance is going worse. I have some lagging while selecting tabs on my Tab View Controller.
Any ideas on how to fix it? (removing changing semanticContentAttribute fix this problem, but I have to use this code for supporting Arabic language)

Related

How to change UIActivityController view to forceRightToLeft always

UIActivityController view is not supporting rtl. I have set UIView.appearance().semanticContentAttribute = .forceRightToLeft in AppDelegate. If device language is English ActivityController is still opening in leftToRight instead of RightToLeft.
It is working fine with device language is Arabic.
Even I have tried to make activity controller view to rightToleft but no luck.
Should be rightToLeft.
You need to add languages in localisation section under info section in Xcode.
for more details checkout this link
output:

Wrong Chromecast buttons position with RTL (right-to-left)

I am using googlecast example.
When I show GCKUIExpandedMediaControlsViewController, all the buttons are in the correct position.
But when I use this part of the code, the buttons overlap each other.
UIView.appearance().semanticContentAttribute = .forceRightToLeft
I don't know if this is important, but the language in the iPhone settings - English.
This is the result that I get
We don't support RTL well now. You can file a feature request here https://developers.google.com/cast/support

Localization in Arabic

I am currently working on Localization. I have my app in English and Arabic. When I change the Language to Arabic all object goes to right, but there are few objects that i want them to be in left. Could please tell how to disable that function on a specific object?
Try setting the semanticContentAttribute property for the particular view to forceLeftToRight
someView.semanticContentAttribute = .forceLeftToRight
You can find more about it semanticContentAttribute in apple docs

Making Large Title Display on iOS 11 Right to Left

As of iOS 11, Apple has added Large Title Display Mode for UINavigationBar and UINavigationItem which makes an effect like this:
We could simply turn this effect on using the following Swift code:
navigationBar.prefersLargeTitles = true
My question is how we can make the large title right to left to be usable for Eastern right to left languages?
Thanks in advance.
I use this approach :
override func viewDidLoad() {
super.viewDidLoad()
navigationController?.navigationBar.subviews[1].semanticContentAttribute = .forceRightToLeft
}
Well, it should be auto RTL for all RTL languages. All you have to do is to set a device language as one of RTL languages. Or, if you debug this in simulator, you can use on of Instruments Xcode is delivered with to simulate RTL while you are actually using LTR language

Change entire app from left-to-right and vice versa on the fly

I am creating an app that will be in English and Arabic. I am using my own localization system because I want to allow users to switch languages themselves from within the app and while the app is running (I am not aware of a way how to do this official Apple way). I would like to switch entire app to right-to-left when user picks arabic language, i.e. switch trailing and leading, text alignment etc.
Is this even possible?
EDIT: I am targeting iOS 7+
Yes, this is possible. From what I am understanding you want to move all of your components to the opposite side and also the text should be written from the right, right?
First of all, you have to set your language to the "AppleLanguage" key in user defaults:
NSUserDefaults.setObject(["ar"], forKey: "AppleLanguage")
Then you have to use auto layout. By default auto layout detects the region depending on the language chosen and when you've set leading and trailing spaces correctly, it will change the position of your text fields for example. If you want some of your components to stay on the same place, you have to use "left" instead of "leading".
If you need to change the direction of app to LTR & RTL then you could use that solution.
//FOR RIGHT TO LEFT
UIView.appearance().semanticContentAttribute = .forceRightToLeft
//FOR LEFT TO RIGHT
UIView.appearance().semanticContentAttribute = .forceLeftToRight
Hope this will solve your problem.
Reference: https://stackoverflow.com/a/48963618/8809657

Resources