Add a custom library for iOS

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.