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 files can only be used after iOS, so if your system needs to be used in versions earlier than iOS5.0, it is best to use. ttf 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:
[Cpp]
UITextView * msg = [[UITextView alloc] init];
Msg. font = [UIFont fontWithName: @ "MicrosoftYaHei" size: 18366f]; // MicrosoftYaHei indicates 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.