Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

enter image description here

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.

like image 931
Seyyed Parsa Neshaei Avatar asked Jan 04 '23 21:01

Seyyed Parsa Neshaei


2 Answers

I use this approach :

override func viewDidLoad() {
    super.viewDidLoad()

    navigationController?.navigationBar.subviews[1].semanticContentAttribute = .forceRightToLeft

}
like image 96
Hosein Abbaspoor Avatar answered Jan 20 '23 15:01

Hosein Abbaspoor


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

like image 31
Slava Nagornyak Avatar answered Jan 20 '23 16:01

Slava Nagornyak