Use custom fonts in IOS

Source: Internet
Author: User

In the previous several projects, the customer required to use the font, but IOS didn't bring this font.

You can only customize the font. The following are several important steps to customize the font:

1. Download the Font Resource file (. TTF or. otf format file)

For example, if you want to use the font, You need to download the font file.

It should be noted that. otf-format files can only be used after ios5, so if your system needs to be used in versions earlier than ios5.0, it is best to use. TTF-format font files.

2. Add the font configuration in info. plist.

Add the downloaded font file to the project and go to info. in the plist file, add the "fonts provided by application" configuration item. For example, the file name of my Font Resource is msyh. TTF, then in info. after this item is added in plist, the effect is as follows:

3. Use a Custom font in the code

Example:

Uitextview * MSG = [[uitextview alloc] init]; MSG. font = [uifont fontwithname: @ "microsoftyahei" Size: 18366f]; // microsoftyahei is the font name. Here it is the font.

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.