Use custom ttf font and iOS custom ttf font on ios
If you want to use a third-party font in the project, you can query the solution on stackoverflow and try to add it. The example is as follows:
1. Add the xx. ttf Library to the project.
2. Add a new line of Fonts provided by application in the xx-Info.plist file of the project, with the name of the Library
3. reference the name of the library. Set the font to [UIFontfontWithName: @ "fontname" size: 24].
UILabel * label = [[UILabel alloc] initWithFrame: CGRectMake (10,100,300, 50)]; label. text = @ "this is a TEST. 123456 "; UIFont * font = [UIFont fontWithName: @" winding CS medium capacity "size: 24]; label. font = font; [self. view addSubview: label];
If you do not know the font name, you can traverse the font for query:
for(NSString *fontfamilyname in [UIFont familyNames]) { NSLog(@"family:'%@'",fontfamilyname); for(NSString *fontName in [UIFont fontNamesForFamilyName:fontfamilyname]) { NSLog(@"\tfont:'%@'",fontName); } NSLog(@"-------------"); }
Example Demo: http://download.csdn.net/detail/duxinfeng2010/7639683
Reference http://stackoverflow.com/questions/15447558/can-not-include-ttf-font-into-project
How does IOS customize UIFont fonts?
Do you mean dayoou.com? The font provided by the iOS system is limited. When customizing UIFont fonts, I usually use the following method: font files (. ttf format or. odf format) Method 1: add the corresponding font (. ttf or. odf) to resurce of the project, use the FontLabel library in cocos2d, FontLabel inherits from UILabel, just like UILabel. FontName directly uses the name of the added resource. Method 2: 1. Add the corresponding font (. ttf or. odf) to the project resurce, such as my. ttf. 2. In info. plist, add a Fonts provided by application (the value corresponding to item0 is my. ttf, and add multiple Fonts in sequence ). 3. When using aLabel. font = [UIFontfontWithName: @ "XXX" size: 30]; note that XXX is not necessarily my, here is return to castle. You can use the following methods to view familyname and fontname: NSArray * familyNames = [UIFont familyNames]; for (NSString * familyName in familyNames) {printf ("Family: % s \ n ", [familyName UTF8String]); NSArray * fontNames = [UIFont fontNamesForFamilyName: familyName]; for (NSString * fontName in fontNames) {printf ("\ tFont: % s \ n ", [fontName UTF8String]) ;}}
How to customize UIFont Fonts
The font provided by the iOS system is limited. When customizing UIFont fonts, I usually use the following method: font files (. ttf format or. odf format) Method 1: add the corresponding font (. ttf or. odf) to resurce of the project, use the FontLabel library in cocos2d, FontLabel inherits from UILabel, just like UILabel. FontName directly uses the name of the added resource. Method 2: 1. Add the corresponding font (. ttf or. odf) to the project resurce, such as my. ttf. 2. In info. plist, add a Fonts provided by application (the value corresponding to item0 is my. ttf, and add multiple Fonts in sequence.