Use custom fonts in iOS and custom fonts in iOS
1. Make sure you have the font file (. ttf or. odf) under the Resources of your project ).
2. In the Info. create a new line in the plist file and add the key: UIAppFonts. The type is Array or Dictionary. Create another key-Value Pair under UIAppFonts, the key is Item 0, and the Value is XXX. ttf (font name, string type), you can add multiple, use the corresponding font name.
3. When the font is used in your project, xx. font = [UIFont fontWithName: @ "XXX" size: 20.0.
Ios code
- -(Void) viewDidLoad {
- NSString * imageName = @ "grid.png ";
- UIImageView * imageView = [[UIImageView alloc] initWithImage: [UIImage imageNamed: imageName];
- ImageView. frame = CGRectMake (20, 20,250,250 );
- UILabel * test = [[UILabel alloc] init];
- Test. frame = CGRectMake (95,215,200, 50 );
- Test. font = [UIFont fontWithName: @ "HAKUYOGuiFanZi3500" size: 30];
- Test. text = @ "Original Image ";
- Test. backgroundColor = [UIColor clearColor];
- [ImageView addSubview: test];
- [Test release];
- [Self. view addSubview: imageView];
- [ImageView release];
- }
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 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]) ;}}