IOS fonts in a detailed

Source: Internet
Author: User

First, iOS native font acquisition and display

1.xib/storyboard Graphic Display

Drag to create a Label control, select the label, modify the label font system to custom in the settings, and then click the Family box to see all the native fonts.

2. Code get fonts and Settings

Many times we are programming with pure code, so how do we set the text font?

In fact, we can use two for loop to remove all the font names, and then according to their own needs to set the font.

Get all font name codes:

1- (void) getallfont{2      for(NSString * Fontfamilynameinch[Uifont Familynames]) {3          for(NSString * FontNameinch[Uifont Fontnamesforfamilyname:fontfamilyname]) {4NSLog (@"font:%@", fontname);5 [Self.fontarray addobject:fontname];6         }7     }8 [Self.tableview Reloaddata];9}

Second, the introduction of third-party fonts (as long as the. TTF font files can be)

1. Add Settings

When we are in the process of development, sometimes iOS native fonts do not meet our needs, we can introduce some third-party fonts (whether Android or Windows), as long as the font is in TTF format, the general iOS program supports inline.

Implementation steps:

1.1 First you want another third-party font file Xxx.ttf (the TTF font I tested was downloaded here: http://www.font5.com.cn/tag.php?tag=TTF%D7%D6%CC%E5) Blog Park seemingly can not insert links, nausea ...

1.2 then drag the. ttf file into the project

1.3 Configuring the Info.plist file

1.4 Then the third-party font was introduced successfully.

2. Display third-party fonts

2.1 Xib/storyboard Graphic display

Whether it's Xib/storyboard graphics showing third-party fonts or code showing third-party fonts, the method is the same as showing the original iOS fonts (see the first step directly)

Source code: Link: https://pan.baidu.com/s/1pLAcf5h Password: S3RF

IOS fonts in a detailed

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.