Add custom font files to iOS

Source: Internet
Author: User

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

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.