iOS development-How to add new fonts to your app

Source: Internet
Author: User

1. Search for font files online (suffix. ttf, or. odf)

2. Import the font library into the resouce of the project

3. In the program add the following code to output all fonts

Nsarray *familynames = [Uifont familynames];
For (NSString *familyname in familynames) {
printf ("Family:%s \ n", [Familyname utf8string]);
Nsarray *fontnames = [Uifont fontnamesforfamilyname:familyname];
For (NSString *fontname in FontNames) {
printf ("\tfont:%s \ n", [FontName utf8string]);
}
}

4. If you add the font to Microsoft Jas, then you can see the Microsoftyahei in NSLog

5. Then create a new line (add row) in your project's Info.plist file, add key: uiappfonts, type array or dictionary, and set a key-value pair under Uiappfonts, key: Item 0, Add value to Xxx.ttf (the name of your font, string type), you can add multiple

6. In your project to use the font when xx.font = [Uifont fontwithname:@ "Microsoftyahei" size:20.0], so you can.

iOS development-How to add new fonts to your app

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.