Change the UITextView Text Direction

Jinah Adam picture Jinah Adam · Feb 5, 2011 · Viewed 7.1k times · Source

my language is not supported by iOS by default, so unicode is not an option so i am using a embedded true type font on a UITextView

it works for the most part, but my issue is like Arabic, and Hebrew my language is written from right to left. So i need to change the direction of the text (Not Text Alignment).

i did some searches, they all talk about NSLocale and stuff, but can it be changed in code? if i can change it to something like Arabic/Hebrew it would work i guess, but it should be done in code, because i dont want change the language of the phone.

so what really are my options for text input? any help would be appreciated.

Thanks.

Answer

Ali Nadalizadeh picture Ali Nadalizadeh · Jun 28, 2011

You can place a "right-to-left embedding" Unicode character at start of each line in the text view.

Name: RIGHT-TO-LEFT EMBEDDING Unicode : 202B UTF8 : E2 80 AB

Note that this character is invisible (No shapes).

The following piece of code replaces the end-of-line characters with a EOL+RTL_EMBEDDING string :

appDescription.text = [rtlDescriptionString stringByReplacingOccurrencesOfString:@"\n" withString:@"\n‫;["