How Do I Change the Font of a UIlabel?
How can I set font of UILabel to one that is not in interface builder list?
I have the fonts file. How do I use it in 开发者_开发知识库app?
http://kgriff.posterous.com/45359635 is a great tutorial on accomplishing this.
Basically, add a key to the info.plist file, and REMEMBER to use the font name that is assigned via the meta attribute in your font's info file, NOT the actual ttf name.
In the plist, add a key "UIAppFonts". Set its value to an array that includes the string "FontName.ttf"
Of course make sure you have added the ttf to the project.
Now in your app, use:
[UIFont fontWithName:@"Font Name as in your Font Book, not the file name" size:12.0f]
Changing the font of a label is done by using the UIFont
object:
self.timeLabel.font = [UIFont fontWithName:(NSString *) size:(CGFloat)];
You can change your font through this code:
UILabel *label = [[UILabel alloc] init];
[label setFrame:CGRectMake(8, 10, 150 ,20)];
label.backgroundColor = [UIColor clearColor];
label.text = [tableArray objectAtIndex:indexPath.row];
label.font = [UIFont fontWithName:@"Arial Rounded MT Bold" size:15];
精彩评论