Sometimes customers are asked to use the founder Orchid Pavilion Black font, but iOS did not bring this font, swollen do, can only customize the font, the following is a few important steps of custom fonts:
1. Download the font resource file (. ttf or. otf file format)
For example, if you want to use the black font of Fangzheng Pavilion, you need to download the black font file of Fangzheng Pavilion.
It is important to note that. otf format files can only be used after iOS5, so if your system needs to be used in a version prior to iOS5.0, it's best to use the. ttf Format font file
2. Add font configuration to Info.plist
Add the downloaded font file to the project, and in the Info.plist file, add the "Fonts provided by Application" configuration item, such as my Microsoft Jas font resource file named: Msyh.ttf, The effect after adding the item in Info.plist is as follows:
3. Use a custom font in your code
Examples of use are:
- Uitextview *msg = [[Uitextview alloc] init];
- Msg.font = [Uifont fontwithname:@ "Noto Sans CJK SC"
size:20.0f]; //Noto Sans CJK SC is the name of the font using a custom font in your codeHow do you know the font for Noto Sans CJK SC, double-click the font file under Mac, find the font in the title bar FontName
Nsarray *array = [uifont familynames];
NSLog (@ "%@", array); Inside the system is added.
s[ using [uifontfontwithname:@ "Noto Sans CJK SC" size:17.0f ]; You can set it up.
3. Use a custom font in your code
IOS Custom font settings