Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a UITextView render top to bottom?

My next project has a requirement to display Japanese text which is displayed top-to-bottom and right-to-left (traditional Japanese writing style). Is it possible to set a UITextViewto layout text in this way? Below is an example of some text written in this way:

 W H
 O E
 R L
 L L
 D O
 ! ,

Also, I need to be able to select it (so UILabel is out). Is this going to turn into a totally custom view?

like image 446
borrrden Avatar asked Sep 12 '12 03:09

borrrden


1 Answers

The answer, as it turns out, is "no it can't."

So, I built my own using Core Text, which is heavily based on the "SimpleTextInput". The key to this view is adding YES to the kCTVerticalFormsAttributeName key. Luckily enough, the selection logic is there already in the project, it is just not being used. I was easily able to add it by calling the appropriate methods inside a pan gesture (there was some monkey business with CTFrameGetLineOrigins overwriting some of its neighboring memory but I was luckily able to resolve it).

like image 169
borrrden Avatar answered Sep 20 '22 23:09

borrrden