Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UILabel - setting font - typeface programmatically in iPhone

Tags:

uilabel

iphone

I have following code in my Application.

tmp=[[UILabel alloc] initWithFrame:label1Frame]; tmp.tag=1; tmp.textColor=[UIColor blackColor]; [tmp setFont:[UIFont fontWithName:@"American Typewriter" size:18]]; tmp.backgroundColor=[UIColor clearColor]; [cell.contentView addSubview:tmp]; [tmp release]; 

Now, I need to know,

======> how to set "Typeface=bold" through code?

like image 618
Sagar Kothari Avatar asked Aug 19 '09 21:08

Sagar Kothari


1 Answers

You will need to use the name of the bold font within the family. To find out if there is a bold version of American Typewriter, try outputting

[UIFont fontNamesForFamilyName:@"AmericanTypewriter"]  

to the console.

In this case, you should use "AmericanTypewriter-Bold".

[UIFont fontNamesForFamilyName:@"AmericanTypewriter-Bold"]  
like image 134
devinfoley Avatar answered Oct 06 '22 09:10

devinfoley