The project would like to use a third-party font, query the solution on the StackOverflow, also toss a while, add success, examples are as follows:
1. Add the Xx.ttf font library to the project
2. Add a new line fonts provided by application in the project's Xx-info.plist file, plus the name of the font library
3. Reference the Font library name, set the font: [uifontfontwithname:@ "FontName" size:];
[OBJC]View Plaincopy
- UILabel *label = [[UILabel alloc] initwithframe:cgrectmake (10, 100, 30 0, 50)];
- Label. Text = @ "This is a test. 123456 ";
- Uifont *font = [Uifont fontwithname:@ "Wen Ding cs medium Line" size:24];
- Label. Font = font;
- [self. View Addsubview:label];
If you do not know the font name, you can traverse the font to query:
[OBJC]View Plaincopy
- 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
iOS third-party fonts