Use a custom font in iOS

Source: Internet
Author: User

This article reprinted to http://blog.csdn.net/yhawaii/article/details/7911290

Several previous projects, customers have asked to use Microsoft Jas font, but iOS did not bring this font, swollen

You can only customize fonts yourself, here are a few important steps for customizing fonts:

1. Download the font resource file (. ttf or. otf file format)

For example, if you want to use Microsoft Jas font, you need to download Microsoft Jas font file.

It is important to note that. otf format files can only be used after iOS5, so if your system needs to be used in a version prior to iOS5.0, it's best to use the. ttf Format font file

2. Add font configuration to Info.plist

Add the downloaded font file to the project, and in the Info.plist file, add the "Fonts provided by Application" configuration item, such as my Microsoft Jas font resource file named: Msyh.ttf, The effect after adding the item in Info.plist is as follows:

3. Use a custom font in your code

Examples of use are:

[CPP]View Plaincopy< param name= "allowfullscreen" value= "false" >
    1. uitextview *msg = [[uitextview  alloc] init];  
    2. msg.font = [uifont fontwithname:@< Span class= "string" > "Microsoftyahei"  size:18.0f]; //microsoftyahei is the name of the font, here is the Microsoft Jas Black font   

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.