1. Add the required library XXX. TTF to the project. Note that it must exist in copy bundle resources. If it is not added
2. Add fonts provided by application to the info. plist file. The default value is array. You can also use dictionary to add XXX. TTF as the value.
You can add multiple font names.
For example:
3. You can use it directly in your project. XX. font = [uifont fontwithname: @ "FZZhunYuan-M02S" Size: 20.0]; (Note: The font name here is familyname, not the file name) by traversing the font, you can get the familyname of the added font, it should be at the end of the array.
// Print all fonts. The new font has been added to nsarray * familynames = [[nsarray alloc] initwitharray: [uifont fonts]; nsarray * fontnames; nsinteger indfamily, indfont; For (indfamily = 0; indfamily <[familynames count]; ++ indfamily) {nslog (@ "Family name: % @", [familynames objectatindex: indfamily]); fontnames = [[nsarray alloc] initwitharray: [uifont fontnamesforfamilyname: [familynames objectatindex: indfamily]; for (indfont = 0; indfont <[fontnames count]; ++ indfont) {nslog (@ "Font Name: % @ ", [fontnames objectatindex: indfont]) ;}}
I just tried it several times without knowing it was familyname.
Font: http://font.knowsky.com/down/6513.html