Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing label text size in code

Tags:

xcode

xcode4

I have to adjust my label text size depending of the device (iPad, iPhone) and these orders just doesn't seem to work. I have my label declared in the interface, set on property as IBOutlet and synthesized. Then:

label.font = [UIFont fontWithName:@"Arial Black" size:50.0];                    
label.minimumFontSize = 50.0;

The size just doesn't change. :S

Any advices?

like image 208
kikovi Avatar asked Aug 23 '11 09:08

kikovi


3 Answers

It may be useful to you to use:

[label setFont:[UIFont systemFontOfSize:35]];

or

[label setFont: [UIFont fontWithName:@"Arial" size:50.0]];
like image 182
Tendulkar Avatar answered Sep 22 '22 23:09

Tendulkar


There's nothing wrong in your code except for the font you are using. It should be :

   label.font = [UIFont fontWithName:@"Arial" size:50];

Actually Arial Black is not supported by iphone. You can check the list of the fonts supported by iPhone here.

like image 42
mayuur Avatar answered Sep 22 '22 23:09

mayuur


You should take a look of the fonts you can use by Default in iOS here is a link: iOS Links http://iosfonts.com/

like image 20
ChecoSchnaider Avatar answered Sep 23 '22 23:09

ChecoSchnaider