Alex Rivera | Logout

UILabel - setting font - typeface programmatically in iPhone

Asked 2009-08-19T21:54:06.127
28

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?

Edit
Report

1 Answer

36

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"] 
answered 2009-08-19T21:58:32.717

Your Answer