1. Identify the font file (. ttf or. odf) you want to use under the resources of your project.
2. Then create a new line in your project's Info.plist file, add key: uiappfonts, type array or dictionary, and set a key value pair under Uiappfonts, key: Item 0, add value to Xxx.ttf (the name of the font, string type), you can add multiple, use the time to write the corresponding font name on the line.
3, in your project to use the font when xx.font = [Uifont fontwithname:@ "XXX" size:20.0], so you can.
iOS code
- -(void) Viewdidload {
- NSString *imagename = @"Grid.png";
- Uiimageview * ImageView = [[Uiimageview alloc] initwithimage:[uiimage Imagenamed:imagename]];
- Imageview.frame = CGRectMake ( 250);
- UILabel *test = [[UILabel alloc] init];
- Test.frame = CGRectMake (215, 50);
- Test.font=[uifont fontwithname:@"HAKUYOGuiFanZi3500" size:30];
- Test.text = @"original picture";
- Test.backgroundcolor = [Uicolor Clearcolor];
- [ImageView Addsubview:test];
- [Test release];
- [Self.view Addsubview:imageview];
- [ImageView release];
- }
Use a custom font in iOS