Text-based apps or plain text pages that are not text subjects often need to configure Special (QI) (strange) fonts other than system fonts, so this skill sometimes needs to get.
The steps for this skill are divided into three stages:
The first step: Download the text file according to PM's request, generally is the. ttf file, here we use a more lovely font to demonstrate
Font can be downloaded directly from Baidu Font.
Unzip the heart of the strawberry. TTF Add the resource path to project (in fact any path can be, in order to follow the specification is placed under supporting files), remember to select the Copy item option.
Step Two: Configure file properties
Click the project file, reach the Properties panel, click the Info button on the left, click the + Sign button to add a fonts provided by Application property, and click Expand This property to add a property: Add the font file name and extension to the property.
Step three: Use fonts based on font names
If you use the name of the strawberry heart directly as the font name, then you must be wrong, because the name of each type of font is usually a unique number. There are two ways to see their real names:
1. Locate the font file, show in Finder, then double-click the font, install the font, and then pop up the font installation interface, the rightmost top line will display the font name
2. Print fonts, use code
Nsarray *array = [Uifont familynames]; for inch Array) { NSLog (@ "family:%@" , familyname); *fontnames = [Uifont fontnamesforfamilyname:familyname]; for inch fontnames) { NSLog (@ "Font name:%@" , Name); } }
Print all fonts, and then use fonts based on the font code or English name. Similar to the following way
Self. Articlelable. Font = [uifont fontwithname:@ "Microsoftyahei" size:+];
PS: Fonts are best used in English, because some Chinese fonts are not supported by iOS.
Add custom font files to iOS