How IOS uses the font library you added _ios

Source: Internet
Author: User

Sometimes you might want to add a Third-party font library for the beauty of the interface. How does that work?
1. Add a font library to your project.
2. Add a new column to the Info.plist as shown below.
If you need to add more than one font, then click "+" to add

3. Add the font added to Info.plist in Target-->build phases-->copy Bundle. Otherwise, there will be no resources found


4. Sometimes the file name and the real font name are different. For example, the screenshot used is Test.ttf, this is not the real font name. At this time we also need to find the real usable fontname.

  For (NSString *familyname in [Uifont Familynames]) {
    NSLog (@ "familyname:%@", familyname);    if ([familyname isequaltostring:@ "test"]) {//start with a judgment condition, it is not possible to find this.
    for (NSString *fontname in [Uifont Fontnamesforfamilyname:familyname]) {
      NSLog (@ "fontname:%@", fontname);    }
    NSLog (@ "=====");
  }

This time, because we are not sure what the name is. Too many results were printed. The simple way to do this is to double-click the font library and use the font book to open it by default. This is the status bar that shows the real familyname. In this way, we can easily search the console for the desired results through the printed results above.

**familyname****:****fzshoujinshu-s10t**
**fontname:fzsjsfw--gb1-0**
PS: In practice, we should use FontName, which is " fzsjsfw--gb1-0 "

 uifont *font = [Uifont fontwithname:@" fzsjsfw--gb1-0 "size:12];

The above is the entire content of this article, I hope to help you learn.

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.