Allen Bargi
Allen Bargi

Reputation: 15172

How to change the writing direction in iPhone UITextView or UITextField

Right now if you type something in a right to left language and tap and hold, the copy and paste menu will have an extra option for changing the writing direction form "left to right" to "right to left".

I want to set this option in the code so that my UITextView writing direction would be right to left by default.

Does anyone know how I can do that. I searched all over the web and SDK and tried everything with no luck. I would be grateful if anyone can help.

Upvotes: 9

Views: 3367

Answers (4)

Masoud Roosta
Masoud Roosta

Reputation: 475

if you want set text writing direction right to left in uitextview

"your UITextview".makeTextWritingDirectionRightToLeft(true)

Upvotes: 0

gpabich
gpabich

Reputation: 1

I think you can use something like:

Swift:

func makeTextWritingDirectionRightToLeft(_ sender: Any?)

Objective C:

(void)makeTextWritingDirectionRightToLeft:(id)sender;

Look it up in the Method Reference

Upvotes: -1

Stan
Stan

Reputation: 142

Hope this can help

divide the text in the UITextView by line,and change NSString from "left to right" to "right to left" is quite simple

Upvotes: 1

Syed Faraz Haider Zaidi
Syed Faraz Haider Zaidi

Reputation: 1367

check may be this will help you.

setTextAlignment:UITextAlignmentRight;

Upvotes: 1

Related Questions