I am new to iPhone,
How do I vertically align my text in the UILabel?
Here is my Code snippet,
UILabel *lbl=[[UILabel alloc]init];
lbl.frame=CGRectMake(10,10,100,100);
lbl.backgroundColor=[UIColor clearColor];
lbl.font=[UIFont systemFontOfSize:13];
lbl.text=@"123456";
[scrollVw addSubview:lbl];
text displayed is in the format of 123456 but i want text should be display vertically like,
6
5
4
3
2
1
Any help will be appriciated.
Its impossible to align the text in
UILabelvertically. But, you can dynamically change the height of the label usingsizeWithFont:method ofNSString, and just set its x and y as you want.As an alternative you can use
UITextField. It supports thecontentVerticalAlignmentpeoperty as it is a subclass ofUIControl. You have to set itsuserInteractionEnabledtoNOto prevent user from typing text on it.EDIT 1
Well instead of a UILabel , Make a UITableView like :-
EDIT 2 Found the method using UILabels too !! 🙂 Check this out….