标签:
今天做了一个自定义字体的lable程序,设计说系统的不符合艺术气息,所以设计了一份自定义的字体,添加到工程当中。
1.第一步找到你想用的字体的 ttf 格式。加入到你的工程的resouce目录下。
2.在工程的plist中AddRow,“Fonts provided by application” ,然后添加key为item0,value为你刚才加入的Aragones.TTF 。
是这样,可以添加多个,使用的时候写对应字体名字就行
注意:
在程序中先加入这段代码,运行,
NSArray *familyNames =[[NSArray alloc]initWithArray:[UIFont familyNames]]; NSArray *fontNames; NSInteger indFamily, indFont; NSLog(@"[familyNames count]===%d",[familyNames count]); for(indFamily=0;indFamily<[familyNames count];++indFamily) { NSLog(@"Family name: %@", [familyNames objectAtIndex:indFamily]); fontNames =[[NSArray alloc]initWithArray:[UIFont fontNamesForFamilyName:[familyNames objectAtIndex:indFamily]]]; for(indFont=0; indFont<[fontNames count]; ++indFont) { NSLog(@"Font name: %@",[fontNames objectAtIndex:indFont]); } [fontNames release]; } [familyNames release];
2012-10-20 21:56:21.321 MyAnimationTest[5397:c07] Family name: HAKUYOGuiFanZi3500 2012-10-20 21:56:21.321 MyAnimationTest[5397:c07] Font name: HAKUYOGuiFanZi3500 2012-10-20 21:56:21.322 MyAnimationTest[5397:c07] Family name: Didot 2012-10-20 21:56:21.322 MyAnimationTest[5397:c07] Font name: Didot-Italic 2012-10-20 21:56:21.322 MyAnimationTest[5397:c07] Font name: Didot 2012-10-20 21:56:21.323 MyAnimationTest[5397:c07] Font name: Didot-Bold 2012-10-20 21:56:21.323 MyAnimationTest[5397:c07] Family name: Bodoni 72 Smallcaps 2012-10-20 21:56:21.323 MyAnimationTest[5397:c07] Font name: BodoniSvtyTwoSCITCTT-Book
效果:
你可以在http://www.webpagepublicity.com/free-fonts.html下载更多ttf字体。
iOS如何添加应用自己的字体------lable设置自定义字体
标签:
原文地址:http://blog.csdn.net/haogaoming123/article/details/45334575