Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to draw vertical text in UILabel

I'm currently working on drawing vertical Chinese text in a label. Here's what I am trying to achieve, albeit with Chinese Characters:

Express

I've been planning to draw each character, rotate each character 90 degrees to the left, then rotating the entire label via affine transformations to get the final result. However, it feels awfully complicated. Is there an easier way to draw the text without complicated CoreGraphics magic that I'm missing?

like image 692
futureelite7 Avatar asked Mar 09 '12 03:03

futureelite7


People also ask

How do you align text on top of UILabel?

Set the UILabel number of lines equal to 0 . Embed the UILabel inside an UIView . Set the UIView constraints (top, right, left and bottom) to occupy the maximum space the UILabel should grow to. Then set the UILabel to top, right, and left of the UIView and also set a constraint to bottom with distance >= 0 .


2 Answers

Well, You can do like below:

labelObject.numberOfLines = 0; labelObject.lineBreakMode = NSLineBreakByCharWrapping; 

and setFrame with -- height:100, width:20 It will work fine..

like image 136
Loquatious Avatar answered Oct 09 '22 17:10

Loquatious


It works

UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 30, 100)]; lbl.transform = CGAffineTransformMakeRotation((M_PI)/2); 
like image 42
Sanket Pandya Avatar answered Oct 09 '22 16:10

Sanket Pandya