Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UILabel font size?

I can't seem to modify the font size of a UILabel with the following code:

itemTitle.font = [UIFont systemFontOfSize:25]; 

As i increase the number 25 to something greater, it seems to only add a top margin to the label, which consequently pushes the text down so much, so that the text gets cut off at the bottom or completely overflows.

i have another UILabel elsewhere with systemFontOfSize 25, and it's much smaller than the itemTitle text. What's going on? Isn't 25 supposed to be an absolute value?

i am so confused on how to programmatically change font size of uilabels.

like image 495
John Avatar asked May 07 '12 00:05

John


People also ask

How do I change the font size in UILabel?

Change Font And Size Of UILabel In StoryboardSelect the label and then open up the Attribute Inspector (CMD + Option + 5). Select the button on the font box and then you can change your text size or font.


2 Answers

I have modified the UILabel by following code:

label.font=[label.font fontWithSize:25]; 

Try this and see whether is it working in your case or not???

like image 157
xtreme Avatar answered Oct 04 '22 15:10

xtreme


Check that your labels aren't set to automatically resize. In IB, it's called "Autoshrink" and is right beside the font setting. Programmatically, it's called adjustsFontSizeToFitWidth.

like image 25
Rob Napier Avatar answered Oct 04 '22 16:10

Rob Napier