iOS uses a custom font

Source: Internet
Author: User

This article reprinted to http://blog.csdn.net/yesjava/article/details/8447596

1. Download the custom font you want to use, usually in a TTF, OTF file. Here's a hypothetical nokia.ttf.

2. Import the Nokia.ttf file into Xcode's resources

3. Add fonts provided by application in the Xxx.plist file. The type is an array. XXX is the name of your project. Add an entry with a value of "Nokia.ttf".

4. Add the following code to the program initialization code:

Nsarray *familynames = [[Nsarray alloc] Initwitharray:[uifont Familynames]];
Nsarray *fontnames;
Nsinteger indfamily, Indfont;
for (indfamily=0; indfamily<[familynames count]; ++indfamily)
{
NSLog (@ "Family name:%@", [Familynames objectatindex:indfamily]);
FontNames = [[Nsarray alloc] Initwitharray:
[Uifont Fontnamesforfamilyname:
[Familynames objectatindex:indfamily]];
for (indfont=0; indfont<[fontnames count]; ++indfont)
{
NSLog (@ "Font name:%@", [FontNames Objectatindex:indfont]);
}
[FontNames release];
}
[Familynames release];

This allows you to find the name of the font you added by logging, and this is called "Nokiafontguyin".

5. Use this font. Uifont *font=[uifont fontwithname:@ "Nokiafontguyin" size:36];

iOS uses a custom 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.